diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-03 21:49:08 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-03 21:49:08 (GMT) |
commit | 72aeec35a14b6a708e7cbacdf48a07adf999f215 (patch) | |
tree | 7551a884ef5d885b7ba34efaef48d73b94e3ee02 /Lib/ssl.py | |
parent | 5c91242f881f4496034c4b452d5fcc74f66206c8 (diff) | |
parent | 8f85f907e3d72b192b9b073e5505075635720282 (diff) | |
download | cpython-72aeec35a14b6a708e7cbacdf48a07adf999f215.zip cpython-72aeec35a14b6a708e7cbacdf48a07adf999f215.tar.gz cpython-72aeec35a14b6a708e7cbacdf48a07adf999f215.tar.bz2 |
Issue #13636: Weak ciphers are now disabled by default in the ssl module
(except when SSLv2 is explicitly asked for).
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r-- | Lib/ssl.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -98,8 +98,9 @@ _PROTOCOL_NAMES = { } try: from _ssl import PROTOCOL_SSLv2 + _SSLv2_IF_EXISTS = PROTOCOL_SSLv2 except ImportError: - pass + _SSLv2_IF_EXISTS = None else: _PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2" @@ -115,6 +116,11 @@ if _ssl.HAS_TLS_UNIQUE: else: CHANNEL_BINDING_TYPES = [] +# Disable weak or insecure ciphers by default +# (OpenSSL's default setting is 'DEFAULT:!aNULL:!eNULL') +_DEFAULT_CIPHERS = 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2' + + class CertificateError(ValueError): pass @@ -181,7 +187,10 @@ class SSLContext(_SSLContext): __slots__ = ('protocol',) def __new__(cls, protocol, *args, **kwargs): - return _SSLContext.__new__(cls, protocol) + self = _SSLContext.__new__(cls, protocol) + if protocol != _SSLv2_IF_EXISTS: + self.set_ciphers(_DEFAULT_CIPHERS) + return self def __init__(self, protocol): self.protocol = protocol |