summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-01-28 12:01:41 +0100
committerMagnus Ahltorp <map@kth.se>2015-01-28 12:01:41 +0100
commitde464826a3d72079fe716668da1c4922e2cf3ffe (patch)
tree7425a5b92f3d67b2e9dd27ffdb4497818b6a3a51
parent1408e8ebc42399ac3a8fb28e9d0df0cacc86bcd7 (diff)
merge.py: add call to storage/getentry since fetchnewentries no longer gives us the actual entry
-rwxr-xr-xtools/merge.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/merge.py b/tools/merge.py
index e007d7c..1cc75ef 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -54,6 +54,22 @@ def get_new_entries(baseurl):
print "ERROR: fetchnewentries", e.read()
sys.exit(1)
+def get_entry(baseurl, hash):
+ try:
+ params = urllib.urlencode({"hash":base64.b64encode(hash)})
+ result = urllib2.urlopen(baseurl + "ct/storage/getentry?" + params).read()
+ parsed_result = json.loads(result)
+ if parsed_result.get(u"result") == u"ok":
+ entries = parsed_result[u"entries"]
+ assert len(entries) == 1
+ assert base64.b64decode(entries[0]["hash"]) == hash
+ return base64.b64decode(entries[0]["entry"])
+ print "ERROR: getentry", parsed_result
+ sys.exit(1)
+ except urllib2.HTTPError, e:
+ print "ERROR: getentry", e.read()
+ sys.exit(1)
+
def get_curpos(baseurl):
try:
result = urllib2.urlopen(baseurl + "ct/frontend/currentposition").read()
@@ -135,9 +151,9 @@ new_entries = [entry for storagenode in storagenodes for entry in get_new_entrie
print "adding entries"
added_entries = 0
for new_entry in new_entries:
- hash = base64.b64decode(new_entry["hash"])
- entry = base64.b64decode(new_entry["entry"])
+ hash = base64.b64decode(new_entry)
if hash not in certsinlog:
+ entry = get_entry(storagenode, hash)
write_chain(hash, entry)
add_to_logorder(hash)
logorder.append(hash)