#!/usr/bin/python # -*- coding: utf-8 -*- import sys import time import datetime import os import json from precerttools import cleanprecert from monitor_conf import * from josef_lib import * def print_reply(rep, entry, precert): t = datetime.datetime.fromtimestamp(rep['timestamp'] / 1000, UTC()).strftime("%Y-%m-%d %H:%M:%S") log_id = rep["id"] print "Time:", t for log in ctlogs: if str(log_id) == log["id"]: l = log break else: l = {"name" : "Log not found" + log_id} print "Log:", l["name"] if precert: print "Type: Precert" signed_entry = pack_precert(cleanprecert(entry[0][0]), entry[2]) else: print "Type: Cert" signed_entry = pack_cert(entry[0][0]) key = base64.b64decode(log["key"]) try: check_sct_signature(log["url"], signed_entry, rep, precert, key) print "Signature: OK" except: print "Could not verify signature!" print "" source = ctlogs[1] dests = [ctlogs[1]] first = 360 last = 365 entries = get_entries(source["url"], first, last)["entries"] # print entries for log in dests: for item in entries: try: entry = extract_original_entry(item) if entry[2]: precert = True else: precert = False submission = [] for e in entry[0]: submission.append(base64.b64encode(e)) if precert: res = add_prechain(log["url"], {"chain" : submission}) else: res = add_chain(log["url"], {"chain" : submission}) print_reply(res, entry, precert) # time.sleep(5) except KeyboardInterrupt: break except: print "FAILED!"