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

Method test_certificate_chain

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

Source from the content-addressed store, hash-verified

5261 )
5262
5263 def test_certificate_chain(self):
5264 client_context, server_context, hostname = testing_context(
5265 server_chain=False
5266 )
5267 server = ThreadedEchoServer(context=server_context, chatty=False)
5268
5269 with open(SIGNING_CA) as f:
5270 expected_ca_cert = ssl.PEM_cert_to_DER_cert(f.read())
5271
5272 with open(SINGED_CERTFILE_ONLY) as f:
5273 expected_ee_cert = ssl.PEM_cert_to_DER_cert(f.read())
5274
5275 with server:
5276 with client_context.wrap_socket(
5277 socket.socket(),
5278 server_hostname=hostname
5279 ) as s:
5280 s.connect((HOST, server.port))
5281 vc = s.get_verified_chain()
5282 self.assertEqual(len(vc), 2)
5283
5284 ee, ca = vc
5285 self.assertIsInstance(ee, bytes)
5286 self.assertIsInstance(ca, bytes)
5287 self.assertEqual(expected_ca_cert, ca)
5288 self.assertEqual(expected_ee_cert, ee)
5289
5290 uvc = s.get_unverified_chain()
5291 self.assertEqual(len(uvc), 1)
5292 self.assertIsInstance(uvc[0], bytes)
5293
5294 self.assertEqual(ee, uvc[0])
5295 self.assertNotEqual(ee, ca)
5296
5297 def test_internal_chain_server(self):
5298 client_context, server_context, hostname = testing_context()

Callers

nothing calls this directly

Calls 12

testing_contextFunction · 0.85
ThreadedEchoServerClass · 0.85
wrap_socketMethod · 0.80
socketMethod · 0.80
assertIsInstanceMethod · 0.80
assertNotEqualMethod · 0.80
openFunction · 0.50
readMethod · 0.45
connectMethod · 0.45
get_verified_chainMethod · 0.45
assertEqualMethod · 0.45
get_unverified_chainMethod · 0.45

Tested by

no test coverage detected