File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,6 +217,26 @@ def test_ssl(self):
217217
218218 ssl .create_default_context ()
219219
220+ @unittest .skipIf (os .name != "nt" , "Windows-specific OpenSSL uplink regression" )
221+ def test_ssl_with_keylogfile (self ):
222+ # Validate that a SSLContext can be created when SSLKEYLOGFILE is set
223+ # https://github.com/astral-sh/python-build-standalone/issues/640
224+ import ssl
225+
226+ with tempfile .TemporaryDirectory () as td :
227+ keylog_path = str (Path (td ) / "sslkeylog.log" )
228+ original_keylog_path = os .environ .get ("SSLKEYLOGFILE" )
229+ os .environ ["SSLKEYLOGFILE" ] = keylog_path
230+ try :
231+ context = ssl .create_default_context ()
232+ self .assertEqual (context .keylog_filename , keylog_path )
233+ self .assertGreater (len (context .get_ciphers ()), 0 )
234+ finally :
235+ if original_keylog_path is None :
236+ os .environ .pop ("SSLKEYLOGFILE" , None )
237+ else :
238+ os .environ ["SSLKEYLOGFILE" ] = original_keylog_path
239+
220240 @unittest .skipIf (
221241 sys .version_info [:2 ] < (3 , 13 ),
222242 "Free-threaded builds are only available in 3.13+" ,
You can’t perform that action at this time.
0 commit comments