fixed previous commit: one -selfsign option was left
[stack/cam.git] / lib / check.py
1
2 import os
3 from time import time, strftime, localtime
4 from utils import *
5 from paths import *
6 from cfg import *
7
8
9 def check():
10     now = time()
11     warning_days = 15
12     if cfg.has_option('global', 'warning_days'):
13         warning_days = int(cfg.get('global', 'warning_days'))
14     for tag in cfg.sections():
15         if tag == 'global' or tag == 'ca' or tag == 'DEFAULT':
16             continue
17         crt_file = getpath('rsa_crt', tag)
18         crt_date = getcertdate(crt_file)
19         if crt_date:
20             days = int((now - crt_date)/86400)
21             if days > -warning_days:
22                 print '''
23 The certificate '%s' should be renewed!
24 (Expiration date: %s)
25 ''' % (tag, strftime('%d/%m/%Y', localtime(crt_date)))
26