Skip to content

Commit 4e29a6d

Browse files
fix(urllib3): 🐛 could not find urllib3 DEFAULT_CIPHERS (#1505)
1 parent 1ae4152 commit 4e29a6d

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

httpie/ssl_.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,50 @@
44
from httpie.adapters import HTTPAdapter
55
# noinspection PyPackageRequirements
66
from urllib3.util.ssl_ import (
7-
DEFAULT_CIPHERS, create_urllib3_context,
7+
create_urllib3_context,
88
resolve_ssl_version,
99
)
1010

1111

12-
DEFAULT_SSL_CIPHERS = DEFAULT_CIPHERS
12+
# Default ciphers imported from urllib3 as a work around for https://github.com/httpie/httpie/issues/1499
13+
# Removed from urllib3 in this commit: https://github.com/urllib3/urllib3/commit/e5eac0c
14+
####################
15+
# A secure default.
16+
# Sources for more information on TLS ciphers:
17+
#
18+
# - https://wiki.mozilla.org/Security/Server_Side_TLS
19+
# - https://www.ssllabs.com/projects/best-practices/index.html
20+
# - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
21+
#
22+
# The general intent is:
23+
# - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
24+
# - prefer ECDHE over DHE for better performance,
25+
# - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
26+
# security,
27+
# - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
28+
# - disable NULL authentication, MD5 MACs, DSS, and other
29+
# insecure ciphers for security reasons.
30+
# - NOTE: TLS 1.3 cipher suites are managed through a different interface
31+
# not exposed by CPython (yet!) and are enabled by default if they're available.
32+
DEFAULT_SSL_CIPHERS = ":".join(
33+
[
34+
"ECDHE+AESGCM",
35+
"ECDHE+CHACHA20",
36+
"DHE+AESGCM",
37+
"DHE+CHACHA20",
38+
"ECDH+AESGCM",
39+
"DH+AESGCM",
40+
"ECDH+AES",
41+
"DH+AES",
42+
"RSA+AESGCM",
43+
"RSA+AES",
44+
"!aNULL",
45+
"!eNULL",
46+
"!MD5",
47+
"!DSS",
48+
"!AESCCM",
49+
]
50+
)
1351
SSL_VERSION_ARG_MAPPING = {
1452
'ssl2.3': 'PROTOCOL_SSLv23',
1553
'ssl3': 'PROTOCOL_SSLv3',

0 commit comments

Comments
 (0)