Skip to content

Commit c036867

Browse files
committed
take 2
1 parent 220f043 commit c036867

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_ssl.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
HOST = socket_helper.HOST
5050
IS_OPENSSL_3_0_0 = ssl.OPENSSL_VERSION_INFO >= (3, 0, 0)
5151
CAN_GET_SELECTED_OPENSSL_GROUP = ssl.OPENSSL_VERSION_INFO >= (3, 2)
52+
CAN_IGNORE_UNKNOWN_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 3)
5253
CAN_GET_AVAILABLE_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 5)
5354
PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS')
5455

@@ -964,10 +965,14 @@ def test_get_ciphers(self):
964965

965966
def test_set_groups(self):
966967
ctx = ssl.create_default_context()
967-
# Use '?' for X25519 as the latter is not allowed if
968-
# OpenSSL has been built with FIPS module support.
969-
self.assertIsNone(ctx.set_groups('P-256:?X25519'))
970-
self.assertRaises(ssl.SSLError, ctx.set_groups, 'P-256:xxx')
968+
# We use P-256 and P-384 (FIPS 186-4) that are alloed by OpenSSL
969+
# even if FIPS module is enabled. Ignoring unknown groups is only
970+
# supported since OpenSSL 3.3.
971+
self.assertIsNone(ctx.set_groups('P-256:P-384'))
972+
973+
self.assertRaises(ssl.SSLError, ctx.set_groups, 'P-256:foo')
974+
if CAN_IGNORE_UNKNOWN_OPENSSL_GROUPS:
975+
self.assertIsNone(ctx.set_groups('P-256:?foo'))
971976

972977
@unittest.skipUnless(CAN_GET_AVAILABLE_OPENSSL_GROUPS,
973978
"OpenSSL version doesn't support getting groups")

0 commit comments

Comments
 (0)