@@ -2782,6 +2782,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
2782
2782
% (expect_success , stats ['version' ]))
2783
2783
2784
2784
2785
+ def supports_kx_alias (ctx , aliases ):
2786
+ for cipher in ctx .get_ciphers ():
2787
+ for alias in aliases :
2788
+ if f"Kx={ alias } " in cipher ['description' ]:
2789
+ return True
2790
+ return False
2791
+
2792
+
2785
2793
class ThreadedTests (unittest .TestCase ):
2786
2794
2787
2795
@support .requires_resource ('walltime' )
@@ -4042,8 +4050,13 @@ def test_no_legacy_server_connect(self):
4042
4050
sni_name = hostname )
4043
4051
4044
4052
def test_dh_params (self ):
4045
- # Check we can get a connection with ephemeral Diffie-Hellman
4053
+ # Check we can get a connection with ephemeral finite-field
4054
+ # Diffie-Hellman (if supported).
4046
4055
client_context , server_context , hostname = testing_context ()
4056
+ dhe_aliases = {"ADH" , "EDH" , "DHE" }
4057
+ if not (supports_kx_alias (client_context , dhe_aliases )
4058
+ and supports_kx_alias (server_context , dhe_aliases )):
4059
+ self .skipTest ("libssl doesn't support ephemeral DH" )
4047
4060
# test scenario needs TLS <= 1.2
4048
4061
client_context .maximum_version = ssl .TLSVersion .TLSv1_2
4049
4062
try :
@@ -4059,7 +4072,7 @@ def test_dh_params(self):
4059
4072
sni_name = hostname )
4060
4073
cipher = stats ["cipher" ][0 ]
4061
4074
parts = cipher .split ("-" )
4062
- if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts :
4075
+ if not dhe_aliases . intersection ( parts ) :
4063
4076
self .fail ("Non-DH key exchange: " + cipher [0 ])
4064
4077
4065
4078
def test_ecdh_curve (self ):
0 commit comments