From e4476f7e71e0ebbfe5594bc90d22a9d74d638211 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Tue, 31 Mar 2015 16:39:22 +0200 Subject: Pass an SSL context to urrllib2. --- tools/certtools.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/certtools.py b/tools/certtools.py index da5021a..498a2e0 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -90,8 +90,8 @@ def get_root_cert(issuer): def urlopen(url, data=None): try: - opener = urllib2.build_opener(urllib2.HTTPSHandler(context=None)) - except TypeError: + opener = urllib2.build_opener(urllib2.HTTPSHandler(context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))) + except AttributeError: opener = urllib2.build_opener(urllib2.HTTPSHandler()) return opener.open(url, data) @@ -239,8 +239,8 @@ def check_auth_header(authheader, expected_key, publickeydir, data, path): def http_request(url, data=None, key=None, verifynode=None, publickeydir="."): try: - opener = urllib2.build_opener(urllib2.HTTPSHandler(context=None)) - except TypeError: + opener = urllib2.build_opener(urllib2.HTTPSHandler(context=ssl.SSLContext(ssl.PROTOCOL_TLSv1))) + except AttributeError: opener = urllib2.build_opener(urllib2.HTTPSHandler()) (keyname, keyfile) = key -- cgit v1.1