summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2_localnet.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-11-03 19:29:33 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-11-03 19:29:33 (GMT)
commit4ffb0752710f0c0720d4f2af0c4b7ce1ebb9d2bd (patch)
tree5082a5a3f18e25c9f0c7ede2717f7170e11b722f /Lib/test/test_urllib2_localnet.py
parent8cf7c1cff0f1176387118826fffdf1c517405f3a (diff)
downloadcpython-4ffb0752710f0c0720d4f2af0c4b7ce1ebb9d2bd.zip
cpython-4ffb0752710f0c0720d4f2af0c4b7ce1ebb9d2bd.tar.gz
cpython-4ffb0752710f0c0720d4f2af0c4b7ce1ebb9d2bd.tar.bz2
PEP 476: enable HTTPS certificate verification by default (#22417)
Patch by Alex Gaynor with some modifications by me.
Diffstat (limited to 'Lib/test/test_urllib2_localnet.py')
-rw-r--r--Lib/test/test_urllib2_localnet.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index d0a8a0f..e17b225 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -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):