From 07f673a8da5d11aa216ae7738bcb1f8abe039a3f Mon Sep 17 00:00:00 2001 From: Xu Luoming Date: Wed, 4 Feb 2026 16:40:45 +0800 Subject: [PATCH] Add "no OPENSSL_Applink" warning when SSLKEYLOGFILE is set on win32 --- httpcore/_backends/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/httpcore/_backends/__init__.py b/httpcore/_backends/__init__.py index e69de29bb..e96118bb4 100644 --- a/httpcore/_backends/__init__.py +++ b/httpcore/_backends/__init__.py @@ -0,0 +1,17 @@ +import os +import sys +import warnings + +# [Windows Only] SSLKEYLOGFILE can trigger the "no OPENSSL_Applink" error. +# OpenSSL on Windows requires an 'Applink' interface to safely perform I/O +# (like logging keys) across different C-Runtimes (CRT). Since CPython doesn't +# provide this bridge and manages I/O independently, OpenSSL fails to access +# Windows stdio, leading to a crash or the "no OPENSSL_Applink" error. +if os.environ.get("SSLKEYLOGFILE") and sys.platform == "win32": + warnings.warn( + "Detected SSLKEYLOGFILE environment variable, which may cause " + "'no OPENSSL_Applink' errors. If you encounter this issue, try " + "unsetting or removing the variable temporarily.", + UserWarning, + 2, + )