(self)
| 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() |
nothing calls this directly
no test coverage detected