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

Skip to content

Commit 45bde5d

Browse files
committed
merge 3.4 (#25530)
2 parents 86429bd + a9dcdab commit 45bde5d

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

Lib/test/test_ssl.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@ def test_ciphers(self):
784784
@skip_if_broken_ubuntu_ssl
785785
def test_options(self):
786786
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
787-
# OP_ALL | OP_NO_SSLv2 is the default value
788-
self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2,
789-
ctx.options)
790-
ctx.options |= ssl.OP_NO_SSLv3
787+
# OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value
791788
self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3,
792789
ctx.options)
790+
ctx.options |= ssl.OP_NO_TLSv1
791+
self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1,
792+
ctx.options)
793793
if can_clear_options():
794794
ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1
795795
self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3,
@@ -2451,17 +2451,17 @@ def test_protocol_sslv23(self):
24512451
" SSL2 client to SSL23 server test unexpectedly failed:\n %s\n"
24522452
% str(x))
24532453
if hasattr(ssl, 'PROTOCOL_SSLv3'):
2454-
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, 'SSLv3')
2454+
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False)
24552455
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True)
24562456
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1')
24572457

24582458
if hasattr(ssl, 'PROTOCOL_SSLv3'):
2459-
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_OPTIONAL)
2459+
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_OPTIONAL)
24602460
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_OPTIONAL)
24612461
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_OPTIONAL)
24622462

24632463
if hasattr(ssl, 'PROTOCOL_SSLv3'):
2464-
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, 'SSLv3', ssl.CERT_REQUIRED)
2464+
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, ssl.CERT_REQUIRED)
24652465
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
24662466
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, 'TLSv1', ssl.CERT_REQUIRED)
24672467

@@ -2493,8 +2493,8 @@ def test_protocol_sslv3(self):
24932493
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
24942494
if no_sslv2_implies_sslv3_hello():
24952495
# No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
2496-
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, 'SSLv3',
2497-
client_options=ssl.OP_NO_SSLv2)
2496+
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23,
2497+
False, client_options=ssl.OP_NO_SSLv2)
24982498

24992499
@skip_if_broken_ubuntu_ssl
25002500
def test_protocol_tlsv1(self):

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ Library
229229
- Issue #24881: Fixed setting binary mode in Python implementation of FileIO
230230
on Windows and Cygwin. Patch from Akira Li.
231231

232+
- Issue #25530: Disable the vulnerable SSLv3 protocol by default when creating
233+
ssl.SSLContext.
234+
232235
- Issue #25569: Fix memory leak in SSLSocket.getpeercert().
233236

234237
- Issue #25471: Sockets returned from accept() shouldn't appear to be

Modules/_ssl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,8 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version)
22762276
options = SSL_OP_ALL & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
22772277
if (proto_version != PY_SSL_VERSION_SSL2)
22782278
options |= SSL_OP_NO_SSLv2;
2279+
if (proto_version != PY_SSL_VERSION_SSL3)
2280+
options |= SSL_OP_NO_SSLv3;
22792281
SSL_CTX_set_options(self->ctx, options);
22802282

22812283
#ifndef OPENSSL_NO_ECDH

0 commit comments

Comments
 (0)