@@ -2810,6 +2810,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
2810
2810
% (expect_success , stats ['version' ]))
2811
2811
2812
2812
2813
+ def supports_kx_alias (ctx , aliases ):
2814
+ for cipher in ctx .get_ciphers ():
2815
+ for alias in aliases :
2816
+ if f"Kx={ alias } " in cipher ['description' ]:
2817
+ return True
2818
+ return False
2819
+
2820
+
2813
2821
class ThreadedTests (unittest .TestCase ):
2814
2822
2815
2823
@support .requires_resource ('walltime' )
@@ -4070,8 +4078,13 @@ def test_no_legacy_server_connect(self):
4070
4078
sni_name = hostname )
4071
4079
4072
4080
def test_dh_params (self ):
4073
- # Check we can get a connection with ephemeral Diffie-Hellman
4081
+ # Check we can get a connection with ephemeral finite-field
4082
+ # Diffie-Hellman (if supported).
4074
4083
client_context , server_context , hostname = testing_context ()
4084
+ dhe_aliases = {"ADH" , "EDH" , "DHE" }
4085
+ if not (supports_kx_alias (client_context , dhe_aliases )
4086
+ and supports_kx_alias (server_context , dhe_aliases )):
4087
+ self .skipTest ("libssl doesn't support ephemeral DH" )
4075
4088
# test scenario needs TLS <= 1.2
4076
4089
client_context .maximum_version = ssl .TLSVersion .TLSv1_2
4077
4090
try :
@@ -4087,7 +4100,7 @@ def test_dh_params(self):
4087
4100
sni_name = hostname )
4088
4101
cipher = stats ["cipher" ][0 ]
4089
4102
parts = cipher .split ("-" )
4090
- if "ADH" not in parts and "EDH" not in parts and "DHE" not in parts :
4103
+ if not dhe_aliases . intersection ( parts ) :
4091
4104
self .fail ("Non-DH key exchange: " + cipher [0 ])
4092
4105
4093
4106
def test_ecdh_curve (self ):
0 commit comments