summaryrefslogtreecommitdiff
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-11-03 14:29:33 -0500
committerBenjamin Peterson <benjamin@python.org>2014-11-03 14:29:33 -0500
commit56af18f1d69b51f08748d3bb537835b75c291525 (patch)
tree3419f151c61ade21d74dc30a833a1cecd10b8816 /Lib/test/test_ssl.py
parenta013b6cf543ba561f4960e17d9ee0973c47c31e1 (diff)
downloadcpython-56af18f1d69b51f08748d3bb537835b75c291525.tar.gz
PEP 476: enable HTTPS certificate verification by default (#22417)
Patch by Alex Gaynor with some modifications by me.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index e71a400160..f95d3e52a2 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -2337,9 +2337,10 @@ else:
d1 = f.read()
d2 = ''
# now fetch the same data from the HTTPS server
- url = 'https://%s:%d/%s' % (
- HOST, server.port, os.path.split(CERTFILE)[1])
- f = urllib.request.urlopen(url)
+ url = 'https://localhost:%d/%s' % (
+ server.port, os.path.split(CERTFILE)[1])
+ context = ssl.create_default_context(cafile=CERTFILE)
+ f = urllib.request.urlopen(url, context=context)
try:
dlen = f.info().get("content-length")
if dlen and (int(dlen) > 0):