diff options
Diffstat (limited to 'monitor/josef_monitor.py')
-rwxr-xr-x | monitor/josef_monitor.py | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py index 0e02a3c..bce3080 100755 --- a/monitor/josef_monitor.py +++ b/monitor/josef_monitor.py @@ -154,37 +154,35 @@ class ctlog: added, removed = compare_lists(hash_list, loaded_list) if len(added) != 0: - print str(len(added)) + " new roots found for " + self.name - if len(removed) != 0: - print str(len(removed)) + " roots removed for " + self.name + self.log(str(len(added)) + " new roots found") + for item in added: + root_cert = base64.decodestring(roots[hash_list.index(item)]) + subject = get_cert_info(root_cert)["subject"] + issuer = get_cert_info(root_cert)["issuer"] + if subject == issuer: + self.log("New Root: " + item + ", " + subject) + else: + self.log("WTF? Not a root...") + + fn = cert_dir + "/" + item + tempname = fn + ".new" + data = roots[hash_list.index(item)] + open(tempname, 'w').write(data) + mv_file(tempname, fn) - for item in removed: - data = open(cert_dir + "/" + item).read() - - root_cert = base64.decodestring(data) - subject = get_cert_info(root_cert)["subject"] - issuer = get_cert_info(root_cert)["issuer"] - if subject == issuer: - print "Removed Root: " + item + ", " + subject - self.log("Removed Root: " + item + ", " + subject) - else: - print "WTF? Not a root..." - - for item in added: - root_cert = base64.decodestring(roots[hash_list.index(item)]) - subject = get_cert_info(root_cert)["subject"] - issuer = get_cert_info(root_cert)["issuer"] - if subject == issuer: - print "New Root: " + item + ", " + subject - self.log("New Root: " + item + ", " + subject) - else: - print "WTF? Not a root..." - - fn = cert_dir + "/" + item - tempname = fn + ".new" - data = roots[hash_list.index(item)] - open(tempname, 'w').write(data) - mv_file(tempname, fn) + + if len(removed) != 0: + self.log(str(len(removed)) + " roots removed") + for item in removed: + data = open(cert_dir + "/" + item).read() + root_cert = base64.decodestring(data) + subject = get_cert_info(root_cert)["subject"] + issuer = get_cert_info(root_cert)["issuer"] + if subject == issuer: + self.log("Removed Root: " + item + ", " + subject) + else: + self.log("WTF? Not a root...") + def verify_progress(self, old): @@ -359,7 +357,7 @@ def get_proof_by_index(baseurl, index, tree_size): def get_all_roots(base_url): result = urlopen(base_url + "ct/v1/get-roots").read() certs = json.loads(result)["certificates"] - print time.strftime('%H:%M:%S') + " Received " + str(len(certs)) + " certs from " + base_url + # print time.strftime('%H:%M:%S') + " Received " + str(len(certs)) + " root certs from " + base_url return certs @@ -409,6 +407,8 @@ def main(args): while True: time.sleep(INTERVAL) for log in logs: + log.update_roots() + old_sth = log.sth log.update_sth() # Should this be done is later checks fail? (reorder?) if old_sth["timestamp"] != log.sth["timestamp"]: |