diff options
Diffstat (limited to 'Lib/test/test_httplib.py')
| -rw-r--r-- | Lib/test/test_httplib.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index a73a28b..011609b 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -639,18 +639,15 @@ class HTTPSTest(TestCase): server = self.make_server(CERT_fakehostname) context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_REQUIRED + context.check_hostname = True context.load_verify_locations(CERT_fakehostname) h = httplib.HTTPSConnection('localhost', server.port, context=context) with self.assertRaises(ssl.CertificateError): h.request('GET', '/') - # Same with explicit check_hostname=True - h = httplib.HTTPSConnection('localhost', server.port, context=context, - check_hostname=True) - with self.assertRaises(ssl.CertificateError): - h.request('GET', '/') - # With check_hostname=False, the mismatching is ignored - h = httplib.HTTPSConnection('localhost', server.port, context=context, - check_hostname=False) + h.close() + # With context.check_hostname=False, the mismatching is ignored + context.check_hostname = False + h = httplib.HTTPSConnection('localhost', server.port, context=context) h.request('GET', '/nonexistent') resp = h.getresponse() self.assertEqual(resp.status, 404) |
