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

Method test_hostname_checks_common_name

Lib/test/test_ssl.py:3313–3332  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3311 ssl.HAS_NEVER_CHECK_COMMON_NAME, "test requires hostname_checks_common_name"
3312 )
3313 def test_hostname_checks_common_name(self):
3314 client_context, server_context, hostname = testing_context()
3315 assert client_context.hostname_checks_common_name
3316 client_context.hostname_checks_common_name = False
3317
3318 # default cert has a SAN
3319 server = ThreadedEchoServer(context=server_context, chatty=True)
3320 with server:
3321 with client_context.wrap_socket(socket.socket(),
3322 server_hostname=hostname) as s:
3323 s.connect((HOST, server.port))
3324
3325 client_context, server_context, hostname = testing_context(NOSANFILE)
3326 client_context.hostname_checks_common_name = False
3327 server = ThreadedEchoServer(context=server_context, chatty=True)
3328 with server:
3329 with client_context.wrap_socket(socket.socket(),
3330 server_hostname=hostname) as s:
3331 with self.assertRaises(ssl.SSLCertVerificationError):
3332 s.connect((HOST, server.port))
3333
3334 def test_ecc_cert(self):
3335 client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)

Callers

nothing calls this directly

Calls 6

testing_contextFunction · 0.85
ThreadedEchoServerClass · 0.85
wrap_socketMethod · 0.80
socketMethod · 0.80
connectMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected