summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2017-09-15 18:27:30 (GMT)
committerGitHub <noreply@github.com>2017-09-15 18:27:30 (GMT)
commita170fa162dc03f0a014373349e548954fff2e567 (patch)
treeed08062f8462d8b9e98e38b7832e39a85881b4e3 /Lib/test/test_httplib.py
parent4df60f18c64ba2835e68bf3eed08d8002a00f4ac (diff)
downloadcpython-a170fa162dc03f0a014373349e548954fff2e567.zip
cpython-a170fa162dc03f0a014373349e548954fff2e567.tar.gz
cpython-a170fa162dc03f0a014373349e548954fff2e567.tar.bz2
bpo-31346: Use PROTOCOL_TLS_CLIENT/SERVER (#3058)
Replaces PROTOCOL_TLSv* and PROTOCOL_SSLv23 with PROTOCOL_TLS_CLIENT and PROTOCOL_TLS_SERVER. Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 68f6946..ab798a2 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1583,8 +1583,9 @@ class HTTPSTest(TestCase):
import ssl
support.requires('network')
with support.transient_internet('self-signed.pythontest.net'):
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_REQUIRED
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
+ self.assertEqual(context.verify_mode, ssl.CERT_REQUIRED)
+ self.assertEqual(context.check_hostname, True)
context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
h.request('GET', '/')
@@ -1599,8 +1600,7 @@ class HTTPSTest(TestCase):
import ssl
support.requires('network')
with support.transient_internet('self-signed.pythontest.net'):
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_REQUIRED
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.load_verify_locations(CERT_localhost)
h = client.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
with self.assertRaises(ssl.SSLError) as exc_info:
@@ -1620,8 +1620,7 @@ class HTTPSTest(TestCase):
# The (valid) cert validates the HTTP hostname
import ssl
server = self.make_server(CERT_localhost)
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_REQUIRED
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.load_verify_locations(CERT_localhost)
h = client.HTTPSConnection('localhost', server.port, context=context)
self.addCleanup(h.close)
@@ -1634,9 +1633,7 @@ class HTTPSTest(TestCase):
# The (valid) cert doesn't validate the HTTP hostname
import ssl
server = self.make_server(CERT_fakehostname)
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_REQUIRED
- context.check_hostname = True
+ context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.load_verify_locations(CERT_fakehostname)
h = client.HTTPSConnection('localhost', server.port, context=context)
with self.assertRaises(ssl.CertificateError):