Skip to content

Commit da1fe38

Browse files
authored
[3.9] gh-94208: Add even more TLS version/protocol checks for FreeBSD (#98037)
Otherwise, buildbot builds would fail since there's no TLS 1.0/1.1 support.
1 parent 77796d0 commit da1fe38

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,7 @@ Tools/ssl/win32
140140
# Artifacts generated by 3.11 lying around when switching branches:
141141
/_bootstrap_python
142142
/Programs/_freeze_module
143+
/Modules/Setup.bootstrap
144+
/Modules/Setup.stdlib
143145
/Python/deepfreeze/
144146
/Python/frozen_modules/

Lib/test/test_ssl.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,10 @@ def test_constructor(self):
11411141

11421142
def test_protocol(self):
11431143
for proto in PROTOCOLS:
1144-
ctx = ssl.SSLContext(proto)
1145-
self.assertEqual(ctx.protocol, proto)
1144+
if has_tls_protocol(proto):
1145+
with warnings_helper.check_warnings():
1146+
ctx = ssl.SSLContext(proto)
1147+
self.assertEqual(ctx.protocol, proto)
11461148

11471149
def test_ciphers(self):
11481150
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
@@ -1524,7 +1526,10 @@ def test_load_dh_params(self):
15241526

15251527
def test_session_stats(self):
15261528
for proto in PROTOCOLS:
1527-
ctx = ssl.SSLContext(proto)
1529+
if not has_tls_protocol(proto):
1530+
continue
1531+
with warnings_helper.check_warnings():
1532+
ctx = ssl.SSLContext(proto)
15281533
self.assertEqual(ctx.session_stats(), {
15291534
'number': 0,
15301535
'connect': 0,
@@ -1715,13 +1720,14 @@ def test__create_stdlib_context(self):
17151720
self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
17161721
self._assert_context_options(ctx)
17171722

1718-
ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1,
1719-
cert_reqs=ssl.CERT_REQUIRED,
1720-
check_hostname=True)
1721-
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
1722-
self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
1723-
self.assertTrue(ctx.check_hostname)
1724-
self._assert_context_options(ctx)
1723+
with warnings_helper.check_warnings():
1724+
ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1,
1725+
cert_reqs=ssl.CERT_REQUIRED,
1726+
check_hostname=True)
1727+
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
1728+
self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
1729+
self.assertTrue(ctx.check_hostname)
1730+
self._assert_context_options(ctx)
17251731

17261732
ctx = ssl._create_stdlib_context(purpose=ssl.Purpose.CLIENT_AUTH)
17271733
self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLS)

0 commit comments

Comments
 (0)