summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-05-04 14:26:56 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-05-04 14:26:56 (GMT)
commitf340c21ca9433a712b2ccf4309c98b20fb28b646 (patch)
treed5330ba7b70c4fae3a9307effcb4896797356db5 /Lib/test/test_ssl.py
parentf072b45e34be8782a2ed5705be2eed5ed35980fa (diff)
parent16f6f8338b649345ff6de7c49b1d691102ef3b22 (diff)
downloadcpython-f340c21ca9433a712b2ccf4309c98b20fb28b646.zip
cpython-f340c21ca9433a712b2ccf4309c98b20fb28b646.tar.gz
cpython-f340c21ca9433a712b2ccf4309c98b20fb28b646.tar.bz2
Fix test connecting to sha256.tbs-internet.com.
The certificate has changed and the test now needs SNI to pass.
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index ada3c4b..d2839dd 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -830,13 +830,18 @@ class NetworkedTests(unittest.TestCase):
# SHA256 was added in OpenSSL 0.9.8
if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
+ # sha256.tbs-internet.com needs SNI to use the correct certificate
+ if not ssl.HAS_SNI:
+ self.skipTest("SNI needed for this test")
# https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
remote = ("sha256.tbs-internet.com", 443)
sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
with support.transient_internet("sha256.tbs-internet.com"):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=sha256_cert,)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(sha256_cert)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="sha256.tbs-internet.com")
try:
s.connect(remote)
if support.verbose: