diff options
author | Magnus Ahltorp <map@kth.se> | 2015-01-28 12:01:41 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2015-02-20 14:12:47 +0100 |
commit | 7d9413dcea9645cfa0f8887ac7536682ff5777f0 (patch) | |
tree | 356ec7d1414c3a02f328fc05763eee477cfcb55e | |
parent | 9168bd99fcbd53ca3d7714fb4e1c883dcd8cbd9c (diff) |
merge.py: add call to storage/getentry since fetchnewentries no longer gives us the actual entry
-rwxr-xr-x | tools/merge.py | 20 |
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) |