cpython: aa2eb034c4f7 (original) (raw)

Mercurial > cpython

changeset 89942:aa2eb034c4f7

Merge the patch for issue #21013 into default [#21013]

Donald Stufft donald@stufft.io
date Sun, 23 Mar 2014 19:12:13 -0400
parents fa89769a4279(current diff)92efd86d1a38(diff)
children dd02c32f42f7
files Misc/NEWS
diffstat 4 files changed, 70 insertions(+), 16 deletions(-)[+] [-] Doc/library/ssl.rst 27 Lib/ssl.py 30 Lib/test/test_ssl.py 26 Misc/NEWS 3

line wrap: on

line diff

--- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -250,13 +250,13 @@ purposes. :const:None, this function can choose to trust the system's default CA certificates instead.

+

+ .. versionadded:: 3.4

--- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -179,7 +179,7 @@ else: 'DH+RC4:RSA+RC4:!aNULL:!eNULL:!MD5' ) -# Restricted and more secure ciphers +# Restricted and more secure ciphers for the server side

This list has been explicitly chosen to:

* Prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE)

* Prefer ECDHE over DHE for better performance

@@ -188,7 +188,7 @@ else:

* Then Use 3DES as fallback which is secure but slow

* Disable NULL authentication, NULL encryption, MD5 MACs, DSS, and RC4 for

security reasons

-_RESTRICTED_CIPHERS = ( +_RESTRICTED_SERVER_CIPHERS = ( 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:' 'DH+HIGH:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:!aNULL:' '!eNULL:!MD5:!DSS:!RC4' @@ -404,17 +404,35 @@ def create_default_context(purpose=Purpo """ if not isinstance(purpose, _ASN1Object): raise TypeError(purpose)

+

+ # SSLv2 considered harmful. context.options |= OP_NO_SSLv2 +

+ # disable compression to prevent CRIME attacks (OpenSSL 1.0+) context.options |= getattr(_ssl, "OP_NO_COMPRESSION", 0)

+ if purpose == Purpose.SERVER_AUTH:

+

+

+ if cafile or capath or cadata: context.load_verify_locations(cafile, capath, cadata) elif context.verify_mode != CERT_NONE:

--- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1014,23 +1014,43 @@ class ContextTests(unittest.TestCase): def test_create_default_context(self): ctx = ssl.create_default_context()

with open(SIGNING_CA) as f: cadata = f.read() ctx = ssl.create_default_context(cafile=SIGNING_CA, capath=CAPATH, cadata=cadata)

ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)

def test__create_stdlib_context(self): ctx = ssl._create_stdlib_context()

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -26,6 +26,9 @@ Core and Builtins Library ------- +- Issue #21013: Enhance ssl.create_default_context() when used for server side