Add support for SSL client certificate authentication (#3435)

Adds `--client-certificate`, `--client-certificate-key`, `--client-certificate-password`

Authored-by: coletdjnz
Co-authored-by: df <fieldhouse@gmx.net>
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
This commit is contained in:
coletdev
2022-05-02 19:59:45 +12:00
committed by GitHub
parent afac4caa7d
commit bb58c9ed5c
16 changed files with 176 additions and 0 deletions

View File

@@ -936,6 +936,14 @@ def make_HTTPS_handler(params, **kwargs):
for storename in ('CA', 'ROOT'):
_ssl_load_windows_store_certs(context, storename)
context.set_default_verify_paths()
client_certfile = params.get('client_certificate')
if client_certfile:
try:
context.load_cert_chain(
client_certfile, keyfile=params.get('client_certificate_key'),
password=params.get('client_certificate_password'))
except ssl.SSLError:
raise YoutubeDLError('Unable to load client certificate')
return YoutubeDLHTTPSHandler(params, context=context, **kwargs)