@@ -2695,10 +2695,7 @@ def test_check_hostname(self):
26952695 def test_ecc_cert (self ):
26962696 client_context = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
26972697 client_context .load_verify_locations (SIGNING_CA )
2698- client_context .set_ciphers (
2699- 'TLS13-AES-128-GCM-SHA256:TLS13-CHACHA20-POLY1305-SHA256:'
2700- 'ECDHE:ECDSA:!NULL:!aRSA'
2701- )
2698+ client_context .set_ciphers ('ECDHE:ECDSA:!NULL:!aRSA' )
27022699 hostname = SIGNED_CERTFILE_ECC_HOSTNAME
27032700
27042701 server_context = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
@@ -3439,17 +3436,16 @@ def test_do_handshake_enotconn(self):
34393436 sock .do_handshake ()
34403437 self .assertEqual (cm .exception .errno , errno .ENOTCONN )
34413438
3442- def test_default_ciphers (self ):
3443- context = ssl .SSLContext (ssl .PROTOCOL_TLS )
3444- try :
3445- # Force a set of weak ciphers on our client context
3446- context .set_ciphers ("DES" )
3447- except ssl .SSLError :
3448- self .skipTest ("no DES cipher available" )
3449- with ThreadedEchoServer (CERTFILE ,
3450- ssl_version = ssl .PROTOCOL_TLS ,
3451- chatty = False ) as server :
3452- with context .wrap_socket (socket .socket ()) as s :
3439+ def test_no_shared_ciphers (self ):
3440+ client_context , server_context , hostname = testing_context ()
3441+ # OpenSSL enables all TLS 1.3 ciphers, enforce TLS 1.2 for test
3442+ client_context .options |= ssl .OP_NO_TLSv1_3
3443+ # Force different suites on client and master
3444+ client_context .set_ciphers ("AES128" )
3445+ server_context .set_ciphers ("AES256" )
3446+ with ThreadedEchoServer (context = server_context ) as server :
3447+ with client_context .wrap_socket (socket .socket (),
3448+ server_hostname = hostname ) as s :
34533449 with self .assertRaises (OSError ):
34543450 s .connect ((HOST , server .port ))
34553451 self .assertIn ("no shared cipher" , server .conn_errors [0 ])
@@ -3490,9 +3486,9 @@ def test_tls1_3(self):
34903486 with context .wrap_socket (socket .socket ()) as s :
34913487 s .connect ((HOST , server .port ))
34923488 self .assertIn (s .cipher ()[0 ], {
3493- 'TLS13-AES-256-GCM-SHA384 ' ,
3494- 'TLS13-CHACHA20-POLY1305-SHA256 ' ,
3495- 'TLS13-AES-128-GCM-SHA256 ' ,
3489+ 'TLS_AES_256_GCM_SHA384 ' ,
3490+ 'TLS_CHACHA20_POLY1305_SHA256 ' ,
3491+ 'TLS_AES_128_GCM_SHA256 ' ,
34963492 })
34973493 self .assertEqual (s .version (), 'TLSv1.3' )
34983494
@@ -3898,23 +3894,20 @@ def cb_wrong_return_type(ssl_sock, server_name, initial_context):
38983894
38993895 def test_shared_ciphers (self ):
39003896 client_context , server_context , hostname = testing_context ()
3901- if ssl .OPENSSL_VERSION_INFO >= (1 , 0 , 2 ):
3902- client_context .set_ciphers ("AES128:AES256" )
3903- server_context .set_ciphers ("AES256" )
3904- alg1 = "AES256"
3905- alg2 = "AES-256"
3906- else :
3907- client_context .set_ciphers ("AES:3DES" )
3908- server_context .set_ciphers ("3DES" )
3909- alg1 = "3DES"
3910- alg2 = "DES-CBC3"
3897+ client_context .set_ciphers ("AES128:AES256" )
3898+ server_context .set_ciphers ("AES256" )
3899+ expected_algs = [
3900+ "AES256" , "AES-256" ,
3901+ # TLS 1.3 ciphers are always enabled
3902+ "TLS_CHACHA20" , "TLS_AES" ,
3903+ ]
39113904
39123905 stats = server_params_test (client_context , server_context ,
39133906 sni_name = hostname )
39143907 ciphers = stats ['server_shared_ciphers' ][0 ]
39153908 self .assertGreater (len (ciphers ), 0 )
39163909 for name , tls_version , bits in ciphers :
3917- if not alg1 in name . split ( "-" ) and alg2 not in name :
3910+ if not any ( alg in name for alg in expected_algs ) :
39183911 self .fail (name )
39193912
39203913 def test_read_write_after_close_raises_valuerror (self ):
0 commit comments