diff options
author | Magnus Ahltorp <map@kth.se> | 2016-03-09 07:47:52 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2016-03-09 07:47:52 +0100 |
commit | d9445aedc64d53192a96a86bd624bb7a2e31208b (patch) | |
tree | 4be292903fb7217f2b023151776c80802632568e /tools/certtools.py | |
parent | 15d65c756fe89aca6cbcc754dc648853ca334095 (diff) |
Make it work with older python-requests
Diffstat (limited to 'tools/certtools.py')
-rw-r--r-- | tools/certtools.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/certtools.py b/tools/certtools.py index 919460e..69e376d 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -102,12 +102,18 @@ def create_ssl_context(cafile=None): def urlget(url, params=None): with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + try: + warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + except AttributeError: + pass return requests.get(url, verify=sslparameters.cafile, params=params) def urlpost(url, data): with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + try: + warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + except AttributeError: + pass return requests.post(url, data=data, verify=sslparameters.cafile) def get_sth(baseurl): @@ -282,7 +288,10 @@ def http_request(url, data=None, key=None, verifynode=None, publickeydir=".", pa sigencode=ecdsa.util.sigencode_der) prepared_req.headers['X-Catlfish-Auth'] = base64.b64encode(signature) + ";key=" + keyname with warnings.catch_warnings(): - warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + try: + warnings.filterwarnings("ignore", category=requests.packages.urllib3.exceptions.SubjectAltNameWarning) + except AttributeError: + pass result = session.send(prepared_req, verify=sslparameters.cafile) result.raise_for_status() authheader = result.headers.get('X-Catlfish-Auth') |