[networking] Respect `SSLKEYLOGFILE` environment variable (#9543)

Authored by: luiso1979
pull/9677/head
luiso1979 2024-04-08 21:53:30 +02:00 zatwierdzone przez GitHub
rodzic df0e138fc0
commit 79a451e576
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 4 dodań i 0 usunięć

Wyświetl plik

@ -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