MCPcopy
hub / github.com/urllib3/urllib3 / supported_tls_versions

Function supported_tls_versions

test/conftest.py:294–328  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

292
293@pytest.fixture(scope="session")
294def supported_tls_versions() -> typing.AbstractSet[str | None]:
295 # We have to create an actual TLS connection
296 # to test if the TLS version is not disabled by
297 # OpenSSL config. Ubuntu 20.04 specifically
298 # disables TLSv1 and TLSv1.1.
299 tls_versions = set()
300
301 _server = HTTPSHypercornDummyServerTestCase
302 _server.setup_class()
303 for _ssl_version_name, min_max_version in (
304 ("PROTOCOL_TLSv1", ssl.TLSVersion.TLSv1),
305 ("PROTOCOL_TLSv1_1", ssl.TLSVersion.TLSv1_1),
306 ("PROTOCOL_TLSv1_2", ssl.TLSVersion.TLSv1_2),
307 ("PROTOCOL_TLS", None),
308 ):
309 _ssl_version = getattr(ssl, _ssl_version_name, 0)
310 if _ssl_version == 0:
311 continue
312 _sock = socket.create_connection((_server.host, _server.port))
313 try:
314 _sock = ssl_.ssl_wrap_socket(
315 _sock,
316 ssl_context=ssl_.create_urllib3_context(
317 cert_reqs=ssl.CERT_NONE,
318 ssl_minimum_version=min_max_version,
319 ssl_maximum_version=min_max_version,
320 ),
321 )
322 except ssl.SSLError:
323 pass
324 else:
325 tls_versions.add(_sock.version())
326 _sock.close()
327 _server.teardown_class()
328 return tls_versions
329
330
331@pytest.fixture(scope="function")

Callers

nothing calls this directly

Calls 5

addMethod · 0.80
setup_classMethod · 0.45
versionMethod · 0.45
closeMethod · 0.45
teardown_classMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…