mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use create_default_context rather than manually creating the context
This commit is contained in:
parent
721bd800cd
commit
03f3eb931d
@ -472,10 +472,7 @@ if has_ssl_verify:
|
||||
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 @@ if has_ssl_verify:
|
||||
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…
x
Reference in New Issue
Block a user