mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02:00
Use create_default_context rather than manually creating the context
This commit is contained in:
parent
721bd800cd
commit
03f3eb931d
2 changed files with 2 additions and 8 deletions
|
|
@ -472,10 +472,7 @@ def match_hostname(cert, hostname):
|
|||
class HTTPSConnection(httplib.HTTPSConnection):
|
||||
|
||||
def __init__(self, ssl_version, *args, **kwargs):
|
||||
context = kwargs['context'] = ssl.SSLContext(ssl_version)
|
||||
cf = kwargs.pop('cert_file')
|
||||
context.load_verify_locations(cf)
|
||||
context.verify_mode = ssl.CERT_REQUIRED
|
||||
kwargs['context'] = ssl.create_default_context(cafile=kwargs.pop('cert_file'))
|
||||
httplib.HTTPSConnection.__init__(self, *args, **kwargs)
|
||||
else:
|
||||
class HTTPSConnection(httplib.HTTPSConnection):
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ def __init__(self, url, code):
|
|||
class HTTPSConnection(httplib.HTTPSConnection):
|
||||
|
||||
def __init__(self, ssl_version, *args, **kwargs):
|
||||
context = kwargs['context'] = ssl.SSLContext(ssl_version)
|
||||
cf = kwargs.pop('cert_file')
|
||||
context.load_verify_locations(cf)
|
||||
context.verify_mode = ssl.CERT_REQUIRED
|
||||
kwargs['context'] = ssl.create_default_context(cafile=kwargs.pop('cert_file'))
|
||||
httplib.HTTPSConnection.__init__(self, *args, **kwargs)
|
||||
else:
|
||||
# Check certificate hostname {{{
|
||||
|
|
|
|||
Loading…
Reference in a new issue