aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluiso1979 <luis.perezsanchez@kopjra.com>2024-04-08 21:53:30 +0200
committerGitHub <noreply@github.com>2024-04-08 21:53:30 +0200
commit79a451e5763eda8b10d00684d5d3378f3255ee01 (patch)
treedb1b1813e8095b493430bdfa1a536e4eff6f7d13
parentdf0e138fc02ae2764a44f2f59fc93c756c4d3ee2 (diff)
[networking] Respect `SSLKEYLOGFILE` environment variable (#9543)
Authored by: luiso1979
-rw-r--r--yt_dlp/networking/_helper.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/yt_dlp/networking/_helper.py b/yt_dlp/networking/_helper.py
index d79dd7953..ecaff36e7 100644
--- a/yt_dlp/networking/_helper.py
+++ b/yt_dlp/networking/_helper.py
@@ -2,6 +2,7 @@ from __future__ import annotations
import contextlib
import functools
+import os
import socket
import ssl
import sys
@@ -121,6 +122,9 @@ def make_ssl_context(
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = verify
context.verify_mode = ssl.CERT_REQUIRED if verify else ssl.CERT_NONE
+ # OpenSSL 1.1.1+ Python 3.8+ keylog file
+ if hasattr(context, 'keylog_filename'):
+ context.keylog_filename = os.environ.get('SSLKEYLOGFILE')
# Some servers may reject requests if ALPN extension is not sent. See:
# https://github.com/python/cpython/issues/85140