From d9445aedc64d53192a96a86bd624bb7a2e31208b Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Wed, 9 Mar 2016 07:47:52 +0100 Subject: Make it work with older python-requests --- tools/certtools.py | 15 ++++++++++++--- 1 file 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') -- cgit v1.1