diff options
Diffstat (limited to 'tools/certtools.py')
-rw-r--r-- | tools/certtools.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/certtools.py b/tools/certtools.py index 1523c97..0009d5d 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -108,13 +108,16 @@ def urlget(url, params=None): pass return requests.get(url, verify=sslparameters.cafile, params=params) -def urlpost(url, data): +def urlpost(url, data, session=None): with warnings.catch_warnings(): try: warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) except AttributeError: pass - return requests.post(url, data=data, verify=sslparameters.cafile) + if session: + return session.post(url, data=data, verify=sslparameters.cafile) + else: + return requests.post(url, data=data, verify=sslparameters.cafile) def get_sth(baseurl): result = urlget(baseurl + "ct/v1/get-sth") @@ -157,9 +160,9 @@ def unpack_tls_array(packed_data, length_len): rest_data = packed_data[length_len+length:] return (unpacked_data, rest_data) -def add_chain(baseurl, submission): +def add_chain(baseurl, submission, session=None): try: - result = urlpost(baseurl + "ct/v1/add-chain", json.dumps(submission)) + result = urlpost(baseurl + "ct/v1/add-chain", json.dumps(submission), session=session) if result.status_code == requests.codes.ok: return result.json() else: @@ -175,10 +178,10 @@ def add_chain(baseurl, submission): print "========================" raise e -def add_prechain(baseurl, submission): +def add_prechain(baseurl, submission, session=None): try: result = urlpost(baseurl + "ct/v1/add-pre-chain", - json.dumps(submission)) + json.dumps(submission), session=session) if result.status_code == requests.codes.ok: return result.json() |