(self)
| 4868 | ) |
| 4869 | |
| 4870 | def test_certificate_chain(self): |
| 4871 | client_context, server_context, hostname = testing_context( |
| 4872 | server_chain=False |
| 4873 | ) |
| 4874 | server = ThreadedEchoServer(context=server_context, chatty=False) |
| 4875 | |
| 4876 | with open(SIGNING_CA) as f: |
| 4877 | expected_ca_cert = ssl.PEM_cert_to_DER_cert(f.read()) |
| 4878 | |
| 4879 | with open(SINGED_CERTFILE_ONLY) as f: |
| 4880 | expected_ee_cert = ssl.PEM_cert_to_DER_cert(f.read()) |
| 4881 | |
| 4882 | with server: |
| 4883 | with client_context.wrap_socket( |
| 4884 | socket.socket(), |
| 4885 | server_hostname=hostname |
| 4886 | ) as s: |
| 4887 | s.connect((HOST, server.port)) |
| 4888 | vc = s.get_verified_chain() |
| 4889 | self.assertEqual(len(vc), 2) |
| 4890 | |
| 4891 | ee, ca = vc |
| 4892 | self.assertIsInstance(ee, bytes) |
| 4893 | self.assertIsInstance(ca, bytes) |
| 4894 | self.assertEqual(expected_ca_cert, ca) |
| 4895 | self.assertEqual(expected_ee_cert, ee) |
| 4896 | |
| 4897 | uvc = s.get_unverified_chain() |
| 4898 | self.assertEqual(len(uvc), 1) |
| 4899 | self.assertIsInstance(uvc[0], bytes) |
| 4900 | |
| 4901 | self.assertEqual(ee, uvc[0]) |
| 4902 | self.assertNotEqual(ee, ca) |
| 4903 | |
| 4904 | def test_internal_chain_server(self): |
| 4905 | client_context, server_context, hostname = testing_context() |
nothing calls this directly
no test coverage detected