diff options
author | Linus Nordberg <linus@nordu.net> | 2017-10-26 16:50:07 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-10-26 16:50:07 +0200 |
commit | 9349ea5d490dac5d45040d859944a58111d8d632 (patch) | |
tree | f18c61b7907bfc24ef4bd23f6dd22278e9a1971d | |
parent | ea51000b953673efd413245f7c4bb377fbfd2157 (diff) |
Submit certificates on the same http session.
Patch by Magnus Ahltorp from map/submission-fix.
-rwxr-xr-x | tools/submitcert.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/submitcert.py b/tools/submitcert.py index 4e4f3c1..9d96148 100755 --- a/tools/submitcert.py +++ b/tools/submitcert.py @@ -19,6 +19,7 @@ import os import signal import select import zipfile +import itertools parser = argparse.ArgumentParser(description='') parser.add_argument('baseurl', help="Base URL for CT server") @@ -49,6 +50,8 @@ else: sth = get_sth(baseurl) +session = None + def submitcert((certfile, cert)): timing = timing_point() certchain = get_certs_from_string(cert) @@ -68,12 +71,12 @@ def submitcert((certfile, cert)): cleanedcert = cleanprecert(precert, issuer=issuer) signed_entry = pack_precert(cleanedcert, issuer_key_hash) leafcert = cleanedcert - result = add_prechain(baseurl, {"chain":map(base64.b64encode, [precert] + certchain)}) + result = add_prechain(baseurl, {"chain":map(base64.b64encode, [precert] + certchain)}, session=session) else: signed_entry = pack_cert(certchain[0]) leafcert = certchain[0] issuer_key_hash = None - result = add_chain(baseurl, {"chain":map(base64.b64encode, certchain)}) + result = add_chain(baseurl, {"chain":map(base64.b64encode, certchain)}, session=session) except SystemExit: print "EXIT:", certfile select.select([], [], [], 1.0) @@ -171,7 +174,12 @@ def save_sct(sct, sth, leafcert, issuer_key_hash): sctlog.write("\n") sctlog.close() -p = Pool(args.parallel, lambda: signal.signal(signal.SIGINT, signal.SIG_IGN)) +def worker_init(): + signal.signal(signal.SIGINT, signal.SIG_IGN) + global session + session = requests.sessions.Session() + +p = Pool(args.parallel, worker_init) nsubmitted = 0 lastprinted = 0 @@ -181,7 +189,7 @@ ncerts = get_ncerts(certfiles) print ncerts, "certs" -certs = get_all_certificates(certfiles) +certs = itertools.islice(get_all_certificates(certfiles), ncerts) errors = 0 |