4 from time import time, strftime, localtime
6 from templates import *
14 if len(args) > 0 and args[0] == '-v':
19 List of known certificates for '%s' CA:
24 sections = cfg.sections()
27 if sec == 'ca' or sec == 'global':
30 crt_file = getpath('rsa_crt', sec)
31 dsa_crt_file = getpath('dsa_crt', sec)
32 if os.path.exists(crt_file):
33 crt_date = getcertdate(crt_file)
34 days = int((time() - crt_date) / 86400)
36 days_s = '%d days ago' % days
38 days_s = '%d days left' % (-days)
40 m = 'EXPIRED %s' % days_s.upper()
44 m = '\n%21s Expiration: %s (%s)' % \
46 strftime('%d %b %Y', localtime(crt_date)),
49 m = 'exp. %s' % strftime('%d/%m/%Y',
55 print '%3d. %s%-15s %s [%s] - %s' % (i, star, sec, cfg.get(sec, 'cn'), cfg.get(sec, 'alt_names').replace('\n', ' '), m)
56 if star != '*' and verbose:
58 for hname, hash in [ ('MD5', 'md5'), ('SHA1', 'sha1') ]:
59 for cypher, file in [ ( 'RSA', crt_file), ( 'DSA', dsa_crt_file ) ]:
60 fp = fingerprint(hash, file)
61 print '%21s %s %s fingerprint: %s' % ('', cypher, hname, fp)
67 (* = certificate does not exist, create with 'cam gen <name>')