Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d4d173

Browse files
authored
bpo-31518: Change TLS protocol for Debian (python#3661)
Debian Unstable has disabled TLS 1.0 and 1.1 for SSLv23_METHOD(). Change TLS/SSL protocol of some tests to PROTOCOL_TLS or PROTOCOL_TLSv1_2 to make them pass on Debian. Signed-off-by: Christian Heimes <[email protected]>
1 parent 8a7f1f4 commit 8d4d173

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

Lib/test/test_ftplib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,11 @@ def test_auth_ssl(self):
710710
self.client.auth()
711711
self.assertRaises(ValueError, self.client.auth)
712712
finally:
713-
self.client.ssl_version = ssl.PROTOCOL_TLSv1
713+
self.client.ssl_version = ssl.PROTOCOL_TLS
714714

715715
def test_context(self):
716716
self.client.quit()
717-
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
717+
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
718718
self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
719719
context=ctx)
720720
self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
@@ -739,7 +739,7 @@ def test_context(self):
739739

740740
def test_check_hostname(self):
741741
self.client.quit()
742-
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
742+
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS)
743743
ctx.verify_mode = ssl.CERT_REQUIRED
744744
ctx.check_hostname = True
745745
ctx.load_verify_locations(CAFILE)

Lib/test/test_httplib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ def test_networked_good_cert(self):
860860
import ssl
861861
test_support.requires('network')
862862
with test_support.transient_internet('self-signed.pythontest.net'):
863-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
863+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
864864
context.verify_mode = ssl.CERT_REQUIRED
865865
context.load_verify_locations(CERT_selfsigned_pythontestdotnet)
866866
h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
@@ -874,7 +874,7 @@ def test_networked_bad_cert(self):
874874
import ssl
875875
test_support.requires('network')
876876
with test_support.transient_internet('self-signed.pythontest.net'):
877-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
877+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
878878
context.verify_mode = ssl.CERT_REQUIRED
879879
context.load_verify_locations(CERT_localhost)
880880
h = httplib.HTTPSConnection('self-signed.pythontest.net', 443, context=context)
@@ -895,7 +895,7 @@ def test_local_good_hostname(self):
895895
# The (valid) cert validates the HTTP hostname
896896
import ssl
897897
server = self.make_server(CERT_localhost)
898-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
898+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
899899
context.verify_mode = ssl.CERT_REQUIRED
900900
context.load_verify_locations(CERT_localhost)
901901
h = httplib.HTTPSConnection('localhost', server.port, context=context)
@@ -907,7 +907,7 @@ def test_local_bad_hostname(self):
907907
# The (valid) cert doesn't validate the HTTP hostname
908908
import ssl
909909
server = self.make_server(CERT_fakehostname)
910-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
910+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
911911
context.verify_mode = ssl.CERT_REQUIRED
912912
context.check_hostname = True
913913
context.load_verify_locations(CERT_fakehostname)

Lib/test/test_ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ def __init__(self, certificate=None, ssl_version=None,
17741774
else:
17751775
self.context = ssl.SSLContext(ssl_version
17761776
if ssl_version is not None
1777-
else ssl.PROTOCOL_TLSv1)
1777+
else ssl.PROTOCOL_TLS)
17781778
self.context.verify_mode = (certreqs if certreqs is not None
17791779
else ssl.CERT_NONE)
17801780
if cacerts:

Lib/test/test_urllib2_localnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def test_https_sni(self):
577577
sni_name = [None]
578578
def cb_sni(ssl_sock, server_name, initial_context):
579579
sni_name[0] = server_name
580-
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
580+
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
581581
context.set_servername_callback(cb_sni)
582582
handler = self.start_https_server(context=context, certfile=CERT_localhost)
583583
context = ssl.create_default_context(cafile=CERT_localhost)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Debian Unstable has disabled TLS 1.0 and 1.1 for SSLv23_METHOD(). Change
2+
TLS/SSL protocol of some tests to PROTOCOL_TLS or PROTOCOL_TLSv1_2 to make
3+
them pass on Debian.

0 commit comments

Comments
 (0)