Skip to content

Commit be2d218

Browse files
gh-131050: skip test_dh_params when TLS library lacks FFDHE ciphersuites (#131051)
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent a594998 commit be2d218

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Lib/test/test_ssl.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -2782,6 +2782,14 @@ def try_protocol_combo(server_protocol, client_protocol, expect_success,
27822782
% (expect_success, stats['version']))
27832783

27842784

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+
27852793
class ThreadedTests(unittest.TestCase):
27862794

27872795
@support.requires_resource('walltime')
@@ -4042,8 +4050,13 @@ def test_no_legacy_server_connect(self):
40424050
sni_name=hostname)
40434051

40444052
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).
40464055
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")
40474060
# test scenario needs TLS <= 1.2
40484061
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
40494062
try:
@@ -4059,7 +4072,7 @@ def test_dh_params(self):
40594072
sni_name=hostname)
40604073
cipher = stats["cipher"][0]
40614074
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):
40634076
self.fail("Non-DH key exchange: " + cipher[0])
40644077

40654078
def test_ecdh_curve(self):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``test_ssl.test_dh_params`` is skipped if the underlying TLS library does not support finite-field ephemeral Diffie-Hellman.

0 commit comments

Comments
 (0)