summaryrefslogtreecommitdiff
path: root/tools/merge.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/merge.py')
-rwxr-xr-xtools/merge.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/merge.py b/tools/merge.py
index 1cc75ef..2b83f54 100755
--- a/tools/merge.py
+++ b/tools/merge.py
@@ -4,20 +4,29 @@
# Copyright (c) 2014, NORDUnet A/S.
# See LICENSE for licensing information.
+import argparse
import json
import base64
import urllib
import urllib2
import sys
import time
-from certtools import build_merkle_tree, create_sth_signature, check_sth_signature
+from certtools import build_merkle_tree, create_sth_signature, check_sth_signature, get_eckey_from_file
-ctbaseurl = "https://127.0.0.1:8080/"
-frontendnodes = ["https://127.0.0.1:8082/"]
-storagenodes = ["https://127.0.0.1:8081/"]
+parser = argparse.ArgumentParser(description="")
+parser.add_argument("--baseurl", metavar="url", help="Base URL for CT server", required=True)
+parser.add_argument("--frontend", action="append", metavar="url", help="Base URL for frontend server", required=True)
+parser.add_argument("--storage", action="append", metavar="url", help="Base URL for storage server", required=True)
+parser.add_argument("--mergedb", metavar="dir", help="Merge database directory", required=True)
+parser.add_argument("--keyfile", metavar="keyfile", help="File containing log key", required=True)
+args = parser.parse_args()
-chainsdir = "../rel/mergedb/chains"
-logorderfile = "../rel/mergedb/logorder"
+ctbaseurl = args.baseurl
+frontendnodes = args.frontend
+storagenodes = args.storage
+
+chainsdir = args.mergedb + "/chains"
+logorderfile = args.mergedb + "/logorder"
def parselogrow(row):
return base64.b16decode(row)
@@ -165,12 +174,7 @@ tree = build_merkle_tree(logorder)
tree_size = len(logorder)
root_hash = tree[-1][0]
timestamp = int(time.time() * 1000)
-privatekey = base64.decodestring(
- "MHcCAQEEIMM/FjZ4FSzfENTTwGpTve6CP+IVr"
- "Y7p8OKV634uJI/foAoGCCqGSM49AwEHoUQDQg"
- "AE4qWq6afhBUi0OdcWUYhyJLNXTkGqQ9PMS5l"
- "qoCgkV2h1ZvpNjBH2u8UbgcOQwqDo66z6BWQJ"
- "GolozZYmNHE2kQ==")
+privatekey = get_eckey_from_file(args.keyfile)
tree_head_signature = create_sth_signature(tree_size, timestamp,
root_hash, privatekey)