@@ -2695,10 +2695,7 @@ def test_check_hostname(self):
2695
2695
def test_ecc_cert (self ):
2696
2696
client_context = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
2697
2697
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' )
2702
2699
hostname = SIGNED_CERTFILE_ECC_HOSTNAME
2703
2700
2704
2701
server_context = ssl .SSLContext (ssl .PROTOCOL_TLS_SERVER )
@@ -3439,17 +3436,16 @@ def test_do_handshake_enotconn(self):
3439
3436
sock .do_handshake ()
3440
3437
self .assertEqual (cm .exception .errno , errno .ENOTCONN )
3441
3438
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 :
3453
3449
with self .assertRaises (OSError ):
3454
3450
s .connect ((HOST , server .port ))
3455
3451
self .assertIn ("no shared cipher" , server .conn_errors [0 ])
@@ -3490,9 +3486,9 @@ def test_tls1_3(self):
3490
3486
with context .wrap_socket (socket .socket ()) as s :
3491
3487
s .connect ((HOST , server .port ))
3492
3488
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 ' ,
3496
3492
})
3497
3493
self .assertEqual (s .version (), 'TLSv1.3' )
3498
3494
@@ -3898,23 +3894,20 @@ def cb_wrong_return_type(ssl_sock, server_name, initial_context):
3898
3894
3899
3895
def test_shared_ciphers (self ):
3900
3896
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
+ ]
3911
3904
3912
3905
stats = server_params_test (client_context , server_context ,
3913
3906
sni_name = hostname )
3914
3907
ciphers = stats ['server_shared_ciphers' ][0 ]
3915
3908
self .assertGreater (len (ciphers ), 0 )
3916
3909
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 ) :
3918
3911
self .fail (name )
3919
3912
3920
3913
def test_read_write_after_close_raises_valuerror (self ):
0 commit comments