Skip to content

Commit 63d60d0

Browse files
committed
gh-95280: Fix test_get_ciphers on systems without RSA key exchange
1 parent b1f648e commit 63d60d0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Lib/test/test_ssl.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,20 @@ def test_get_ciphers(self):
938938
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
939939
ctx.set_ciphers('AESGCM')
940940
names = set(d['name'] for d in ctx.get_ciphers())
941-
self.assertIn('AES256-GCM-SHA384', names)
942-
self.assertIn('AES128-GCM-SHA256', names)
941+
expected = {
942+
'AES128-GCM-SHA256',
943+
'ECDHE-ECDSA-AES128-GCM-SHA256',
944+
'ECDHE-RSA-AES128-GCM-SHA256',
945+
'DHE-RSA-AES128-GCM-SHA256',
946+
'AES256-GCM-SHA384',
947+
'ECDHE-ECDSA-AES256-GCM-SHA384',
948+
'ECDHE-RSA-AES256-GCM-SHA384',
949+
'DHE-RSA-AES256-GCM-SHA384',
950+
}
951+
intersection = names.intersection(expected)
952+
self.assertGreaterEqual(
953+
len(intersection), 2, f"\ngot: {sorted(names)}\nexpected: {sorted(expected)}"
954+
)
943955

944956
def test_options(self):
945957
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix problem with ``test_ssl`` ``test_get_ciphers`` on systems that require
2+
perfect forward secrecy (PFS) ciphers.

0 commit comments

Comments
 (0)