-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Subject
On Windows, when environment variable SSLKEYLOGFILE is defined using another environment variable (typically USERPROFILE), requests fail with the error:
File "C:\Program Files\Python312\Lib\site-packages\urllib3\util\ssl_.py", line 369, in create_urllib3_context
context.keylog_filename = sslkeylogfile
^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '%USERPROFILE%\\AppData\\ssl-keys.log'
Environment
This issue is happening for me on Windows 11 with Python 3.12 and urllib3 2.5.0.
import platform
import ssl
import urllib3
print("OS", platform.platform())
print("Python", platform.python_version())
print(ssl.OPENSSL_VERSION)
print("urllib3", urllib3.__version__)returns
>>> import platform
>>> import ssl
>>> import urllib3
>>> print("OS", platform.platform())
OS Windows-11-10.0.26100-SP0
>>> print("Python", platform.python_version())
Python 3.12.3
>>> print(ssl.OPENSSL_VERSION)
OpenSSL 3.0.13 30 Jan 2024
>>> print("urllib3", urllib3.__version__)
urllib3 2.5.0
Steps to Reproduce
The issue is always reproducible when the SSLKEYLOGFILE environment variable is defined with another environment variable.
Root cause is consolidated as defining the SSLKEYLOGFILE environment variable with a raw resolvable path works around the issue.
Expected Behavior
On Windows, environment variable are expanded inside the value of used environment variables.
Actual Behavior
Environment variable(s) inside the value of SSLKEYLOGFILE environment variable are not resolved, ending in a not existing path and a FileNotFound error.