3 'getcertdate', 'fingerprint', 'expired',
4 'cfg2dict', 'mkdir', 'template',
15 def getcertdate(crt_file):
16 if os.path.exists(crt_file):
17 o = commands.getoutput('openssl x509 -in %s -noout -dates' % crt_file)
18 m = re.search(r'notAfter=(.*)', o)
20 return time.mktime(time.strptime(m.group(1),
21 '%b %d %H:%M:%S %Y %Z'))
25 if crtdate < time.time():
30 def fingerprint(hash, crt_file):
31 if os.path.exists(crt_file):
32 o = commands.getoutput('openssl x509 -in %s -noout -fingerprint -%s' % (crt_file, hash))
33 m = re.search(r'=(.*)$', o)
38 def cfg2dict(cfg, section):
40 for k, v in cfg.items(section):
47 print 'created directory \'%s\'' % p
51 def template(file, t, args):
56 def dictmerge(d1, d2):
59 for k, v in d.items():
63 def d2get(d1, d2, k, default=None):
64 return d1.get(k, d2.get(k, default))
67 cmd = "openssl " + ' '.join(["'%s'" % x for x in args])
68 print 'executing "%s"' % cmd