From 7d9413dcea9645cfa0f8887ac7536682ff5777f0 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Wed, 28 Jan 2015 12:01:41 +0100 Subject: merge.py: add call to storage/getentry since fetchnewentries no longer gives us the actual entry --- tools/merge.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tools') 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) -- cgit v1.1