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

Method test_networked_bad_cert

Lib/test/test_httplib.py:2136–2146  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2134
2135 @support.requires_resource('walltime')
2136 def test_networked_bad_cert(self):
2137 # We feed a "CA" cert that is unrelated to the server's cert
2138 import ssl
2139 support.requires('network')
2140 with socket_helper.transient_internet('self-signed.pythontest.net'):
2141 context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
2142 context.load_verify_locations(CERT_localhost)
2143 h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
2144 with self.assertRaises(ssl.SSLError) as exc_info:
2145 h.request('GET', '/')
2146 self.assertEqual(exc_info.exception.reason, 'CERTIFICATE_VERIFY_FAILED')
2147
2148 def test_local_unknown_cert(self):
2149 # The custom cert isn't known to the default trust bundle

Callers

nothing calls this directly

Calls 4

requiresMethod · 0.80
assertRaisesMethod · 0.45
requestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected