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

Skip to content

Commit dec813f

Browse files
committed
ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME
1 parent 50a5dad commit dec813f

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/ssl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ def create_default_context(purpose=Purpose.SERVER_AUTH, *, cafile=None,
383383
context = SSLContext(PROTOCOL_TLSv1)
384384
# SSLv2 considered harmful.
385385
context.options |= OP_NO_SSLv2
386+
# disable compression to prevent CRIME attacks (OpenSSL 1.0+)
387+
context.options |= getattr(_ssl, "OP_NO_COMPRESSION", 0)
386388
# disallow ciphers with known vulnerabilities
387389
context.set_ciphers(_RESTRICTED_CIPHERS)
388390
# verify certs in client mode

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Core and Builtins
1818
Library
1919
-------
2020

21+
- ssl.create_default_context() sets OP_NO_COMPRESSION to prevent CRIME.
22+
2123
- Issue #19802: Add socket.SO_PRIORITY.
2224

2325
- Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with

0 commit comments

Comments
 (0)