[utils] Make ssl work on Python 2.7.8

This commit is contained in:
Philipp Hagemeister 2014-12-13 23:27:21 +01:00
parent 051c46256b
commit a23669220a
1 changed files with 8 additions and 2 deletions

View File

@ -393,8 +393,14 @@ def make_HTTPS_handler(opts_no_check_certificate, **kwargs):
context.options &= ~ssl.OP_NO_SSLv3 # Allow older, not-as-secure SSLv3 context.options &= ~ssl.OP_NO_SSLv3 # Allow older, not-as-secure SSLv3
if opts_no_check_certificate: if opts_no_check_certificate:
context.verify_mode = ssl.CERT_NONE context.verify_mode = ssl.CERT_NONE
return compat_urllib_request.HTTPSHandler(context=context, **kwargs) try:
elif sys.version_info < (3, 2): return compat_urllib_request.HTTPSHandler(context=context, **kwargs)
except TypeError:
# Python 2.7.8
# (create_default_context present but HTTPSHandler has no context=)
pass
if sys.version_info < (3, 2):
import httplib import httplib
class HTTPSConnectionV3(httplib.HTTPSConnection): class HTTPSConnectionV3(httplib.HTTPSConnection):