MCPcopy Index your code
hub / github.com/python/cpython / has_tls_protocol

Function has_tls_protocol

Lib/test/test_ssl.py:188–206  ·  view source on GitHub ↗

Check if a TLS protocol is available and enabled :param protocol: enum ssl._SSLMethod member or name :return: bool

(protocol)

Source from the content-addressed store, hash-verified

186
187
188def has_tls_protocol(protocol):
189 """Check if a TLS protocol is available and enabled
190
191 :param protocol: enum ssl._SSLMethod member or name
192 :return: bool
193 """
194 if isinstance(protocol, str):
195 assert protocol.startswith('PROTOCOL_')
196 protocol = getattr(ssl, protocol, None)
197 if protocol is None:
198 return False
199 if protocol in {
200 ssl.PROTOCOL_TLS, ssl.PROTOCOL_TLS_SERVER,
201 ssl.PROTOCOL_TLS_CLIENT
202 }:
203 # auto-negotiate protocols are always available
204 return True
205 name = protocol.name
206 return has_tls_version(name[len('PROTOCOL_'):])
207
208
209@functools.lru_cache

Callers 5

test_constructorMethod · 0.85
test_min_max_versionMethod · 0.85
test_protocol_tlsv1_2Method · 0.85

Calls 2

has_tls_versionFunction · 0.85
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…