1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/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 json.dumps(rep)
# print entry
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"
print base64.b64encode(entry[2])
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[0]]
first = 153363
last = 153365
entries = get_entries(source["url"], first, last)["entries"]
# print entries
for log in dests:
for item in entries:
try:
# print item
entry = extract_original_entry(item)
# print entry[2]
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 res
# print submission
print_reply(res, entry, precert)
# time.sleep(5)
except KeyboardInterrupt:
break
# except:
# print "FAILED!"
|