@@ -4034,19 +4034,29 @@ def test_no_legacy_server_connect(self):
4034
4034
4035
4035
@unittest .skipIf (Py_DEBUG_WIN32 , "Avoid mixing debug/release CRT on Windows" )
4036
4036
def test_dh_params (self ):
4037
- # Check we can get a connection with ephemeral Diffie-Hellman
4037
+ # Check we can get a connection with ephemeral finite-field Diffie-
4038
+ # Hellman (if supported).
4038
4039
client_context , server_context , hostname = testing_context ()
4040
+ dhe_aliases = ["ADH" , "EDH" , "DHE" ]
4041
+ def supports_dhe (ctx , aliases ) -> bool :
4042
+ for cipher in ctx .get_ciphers ():
4043
+ for alias in aliases :
4044
+ if alias in cipher :
4045
+ return True
4046
+ return False
4047
+ if not (supports_dhe (client_context , dhe_aliases ) and
4048
+ supports_dhe (server_context , dhe_aliases )):
4049
+ self .skipTest ("ssl doesn't support FFDHE" )
4039
4050
# test scenario needs TLS <= 1.2
4040
4051
client_context .maximum_version = ssl .TLSVersion .TLSv1_2
4041
- server_context .load_dh_params (DHFILE )
4042
4052
server_context .set_ciphers ("kEDH" )
4043
4053
server_context .maximum_version = ssl .TLSVersion .TLSv1_2
4044
4054
stats = server_params_test (client_context , server_context ,
4045
4055
chatty = True , connectionchatty = True ,
4046
4056
sni_name = hostname )
4047
4057
cipher = stats ["cipher" ][0 ]
4048
4058
parts = cipher .split ("-" )
4049
- if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts :
4059
+ if all ( a not in parts for a in aliases ) :
4050
4060
self .fail ("Non-DH key exchange: " + cipher [0 ])
4051
4061
4052
4062
def test_ecdh_curve (self ):
0 commit comments