mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
PEP 476: enable HTTPS certificate verification by default (#22417)
Patch by Alex Gaynor with some modifications by me.
This commit is contained in:
parent
8cf7c1cff0
commit
4ffb075271
11 changed files with 116 additions and 69 deletions
|
@ -545,7 +545,8 @@ class TestUrlopen(unittest.TestCase):
|
|||
|
||||
def test_https(self):
|
||||
handler = self.start_https_server()
|
||||
data = self.urlopen("https://localhost:%s/bizarre" % handler.port)
|
||||
context = ssl.create_default_context(cafile=CERT_localhost)
|
||||
data = self.urlopen("https://localhost:%s/bizarre" % handler.port, context=context)
|
||||
self.assertEqual(data, b"we care a bit")
|
||||
|
||||
def test_https_with_cafile(self):
|
||||
|
@ -584,7 +585,8 @@ class TestUrlopen(unittest.TestCase):
|
|||
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
|
||||
context.set_servername_callback(cb_sni)
|
||||
handler = self.start_https_server(context=context, certfile=CERT_localhost)
|
||||
self.urlopen("https://localhost:%s" % handler.port)
|
||||
context = ssl.create_default_context(cafile=CERT_localhost)
|
||||
self.urlopen("https://localhost:%s" % handler.port, context=context)
|
||||
self.assertEqual(sni_name, "localhost")
|
||||
|
||||
def test_sending_headers(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue