diff options
author | Linus Nordberg <linus@nordu.net> | 2016-11-25 10:54:17 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2016-11-25 10:54:17 +0100 |
commit | 9f436ce835aba793cc06525e160bd2e07dd8f7cd (patch) | |
tree | 4a6a0a74cd6b054b51a6ab8f1767caf820970d59 /tools/certtools.py | |
parent | 034c40cc84f28fd970fc649ffe7eb7fe797479a6 (diff) | |
parent | ccfe7c55a5d1658c0f98aac2c45e76444dcd0bc2 (diff) |
Merge remote-tracking branch 'refs/remotes/map/robust-distribution'
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() |