|
4 | 4 | from httpie.adapters import HTTPAdapter |
5 | 5 | # noinspection PyPackageRequirements |
6 | 6 | from urllib3.util.ssl_ import ( |
7 | | - DEFAULT_CIPHERS, create_urllib3_context, |
| 7 | + create_urllib3_context, |
8 | 8 | resolve_ssl_version, |
9 | 9 | ) |
10 | 10 |
|
11 | 11 |
|
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 | +) |
13 | 51 | SSL_VERSION_ARG_MAPPING = { |
14 | 52 | 'ssl2.3': 'PROTOCOL_SSLv23', |
15 | 53 | 'ssl3': 'PROTOCOL_SSLv3', |
|
0 commit comments