(self)
| 1918 | self.assertTrue(s.getpeercert()) |
| 1919 | |
| 1920 | def test_connect_with_context(self): |
| 1921 | # Same as test_connect, but with a separately created context |
| 1922 | ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) |
| 1923 | ctx.check_hostname = False |
| 1924 | ctx.verify_mode = ssl.CERT_NONE |
| 1925 | with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: |
| 1926 | s.connect(self.server_addr) |
| 1927 | self.assertEqual({}, s.getpeercert()) |
| 1928 | # Same with a server hostname |
| 1929 | with ctx.wrap_socket(socket.socket(socket.AF_INET), |
| 1930 | server_hostname="dummy") as s: |
| 1931 | s.connect(self.server_addr) |
| 1932 | ctx.verify_mode = ssl.CERT_REQUIRED |
| 1933 | # This should succeed because we specify the root cert |
| 1934 | ctx.load_verify_locations(SIGNING_CA) |
| 1935 | with ctx.wrap_socket(socket.socket(socket.AF_INET)) as s: |
| 1936 | s.connect(self.server_addr) |
| 1937 | cert = s.getpeercert() |
| 1938 | self.assertTrue(cert) |
| 1939 | |
| 1940 | def test_connect_with_context_fail(self): |
| 1941 | # This should fail because we have no verification certs. Connection |
nothing calls this directly
no test coverage detected