@@ -1685,6 +1685,8 @@ def _assert_context_options(self, ctx):
16851685 if OP_CIPHER_SERVER_PREFERENCE != 0 :
16861686 self .assertEqual (ctx .options & OP_CIPHER_SERVER_PREFERENCE ,
16871687 OP_CIPHER_SERVER_PREFERENCE )
1688+ self .assertEqual (ctx .options & ssl .OP_LEGACY_SERVER_CONNECT ,
1689+ 0 if IS_OPENSSL_3_0_0 else ssl .OP_LEGACY_SERVER_CONNECT )
16881690
16891691 def test_create_default_context (self ):
16901692 ctx = ssl .create_default_context ()
@@ -4073,6 +4075,20 @@ def test_compression_disabled(self):
40734075 sni_name = hostname )
40744076 self .assertIs (stats ['compression' ], None )
40754077
4078+ def test_legacy_server_connect (self ):
4079+ client_context , server_context , hostname = testing_context ()
4080+ client_context .options |= ssl .OP_LEGACY_SERVER_CONNECT
4081+ server_params_test (client_context , server_context ,
4082+ chatty = True , connectionchatty = True ,
4083+ sni_name = hostname )
4084+
4085+ def test_no_legacy_server_connect (self ):
4086+ client_context , server_context , hostname = testing_context ()
4087+ client_context .options &= ~ ssl .OP_LEGACY_SERVER_CONNECT
4088+ server_params_test (client_context , server_context ,
4089+ chatty = True , connectionchatty = True ,
4090+ sni_name = hostname )
4091+
40764092 @unittest .skipIf (Py_DEBUG_WIN32 , "Avoid mixing debug/release CRT on Windows" )
40774093 def test_dh_params (self ):
40784094 # Check we can get a connection with ephemeral Diffie-Hellman
0 commit comments