@@ -4002,19 +4002,29 @@ def test_no_legacy_server_connect(self):
4002
4002
4003
4003
@unittest .skipIf (Py_DEBUG_WIN32 , "Avoid mixing debug/release CRT on Windows" )
4004
4004
def test_dh_params (self ):
4005
- # Check we can get a connection with ephemeral Diffie-Hellman
4005
+ # Check we can get a connection with ephemeral finite-field Diffie-
4006
+ # Hellman (if supported).
4006
4007
client_context , server_context , hostname = testing_context ()
4008
+ dhe_aliases = ["ADH" , "EDH" , "DHE" ]
4009
+ def supports_dhe (ctx , aliases ) -> bool :
4010
+ for cipher in ctx .get_ciphers ():
4011
+ for alias in aliases :
4012
+ if alias in cipher :
4013
+ return True
4014
+ return False
4015
+ if not (supports_dhe (client_context , dhe_aliases ) and
4016
+ supports_dhe (server_context , dhe_aliases )):
4017
+ self .skipTest ("ssl doesn't support FFDHE" )
4007
4018
# test scenario needs TLS <= 1.2
4008
4019
client_context .maximum_version = ssl .TLSVersion .TLSv1_2
4009
- server_context .load_dh_params (DHFILE )
4010
4020
server_context .set_ciphers ("kEDH" )
4011
4021
server_context .maximum_version = ssl .TLSVersion .TLSv1_2
4012
4022
stats = server_params_test (client_context , server_context ,
4013
4023
chatty = True , connectionchatty = True ,
4014
4024
sni_name = hostname )
4015
4025
cipher = stats ["cipher" ][0 ]
4016
4026
parts = cipher .split ("-" )
4017
- if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts :
4027
+ if all ( a not in parts for a in aliases ) :
4018
4028
self .fail ("Non-DH key exchange: " + cipher [0 ])
4019
4029
4020
4030
def test_ecdh_curve (self ):
0 commit comments