mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-24 15:50:32 +01:00
parent
f85e6be42e
commit
4e3d1898a8
@ -2373,13 +2373,20 @@ def make_HTTPS_handler(params, **kwargs):
|
|||||||
context.check_hostname = opts_check_certificate
|
context.check_hostname = opts_check_certificate
|
||||||
context.verify_mode = ssl.CERT_REQUIRED if opts_check_certificate else ssl.CERT_NONE
|
context.verify_mode = ssl.CERT_REQUIRED if opts_check_certificate else ssl.CERT_NONE
|
||||||
if opts_check_certificate:
|
if opts_check_certificate:
|
||||||
# Work around the issue in load_default_certs when there are bad certificates. See:
|
try:
|
||||||
# https://github.com/yt-dlp/yt-dlp/issues/1060,
|
context.load_default_certs()
|
||||||
# https://bugs.python.org/issue35665, https://bugs.python.org/issue4531
|
# Work around the issue in load_default_certs when there are bad certificates. See:
|
||||||
if sys.platform == 'win32':
|
# https://github.com/yt-dlp/yt-dlp/issues/1060,
|
||||||
for storename in ('CA', 'ROOT'):
|
# https://bugs.python.org/issue35665, https://bugs.python.org/issue45312
|
||||||
_ssl_load_windows_store_certs(context, storename)
|
except ssl.SSLError:
|
||||||
context.set_default_verify_paths()
|
# enum_certificates is not present in mingw python. See https://github.com/yt-dlp/yt-dlp/issues/1151
|
||||||
|
if sys.platform == 'win32' and hasattr(ssl, 'enum_certificates'):
|
||||||
|
# Create a new context to discard any certificates that were already loaded
|
||||||
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
|
context.check_hostname, context.verify_mode = True, ssl.CERT_REQUIRED
|
||||||
|
for storename in ('CA', 'ROOT'):
|
||||||
|
_ssl_load_windows_store_certs(context, storename)
|
||||||
|
context.set_default_verify_paths()
|
||||||
return YoutubeDLHTTPSHandler(params, context=context, **kwargs)
|
return YoutubeDLHTTPSHandler(params, context=context, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user