88 resolve_ssl_version ,
99)
1010
11- # We used to import default SSL ciphers via `SSL_CIPHERS` from `urllib3` but it’s been removed,
12- # so we’ve copied the original list here.
13- # Our issue: <https://github.com/httpie/httpie/issues/1499>
14- # Removal commit: <https://github.com/urllib3/urllib3/commit/e5eac0c>
15- DEFAULT_SSL_CIPHERS = ":" .join ([
16- # <urllib3>
17- # A secure default.
18- # Sources for more information on TLS ciphers:
19- #
20- # - https://wiki.mozilla.org/Security/Server_Side_TLS
21- # - https://www.ssllabs.com/projects/best-practices/index.html
22- # - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
23- #
24- # The general intent is:
25- # - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
26- # - prefer ECDHE over DHE for better performance,
27- # - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
28- # security,
29- # - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
30- # - disable NULL authentication, MD5 MACs, DSS, and other
31- # insecure ciphers for security reasons.
32- # - NOTE: TLS 1.3 cipher suites are managed through a different interface
33- # not exposed by CPython (yet!) and are enabled by default if they're available.
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- # </urllib3>
50- ])
11+
5112SSL_VERSION_ARG_MAPPING = {
5213 'ssl2.3' : 'PROTOCOL_SSLv23' ,
5314 'ssl3' : 'PROTOCOL_SSLv3' ,
@@ -119,6 +80,10 @@ def _create_ssl_context(
11980 cert_reqs = ssl .CERT_REQUIRED if verify else ssl .CERT_NONE
12081 )
12182
83+ @classmethod
84+ def get_default_ciphers_names (cls ):
85+ return [cipher ['name' ] for cipher in cls ._create_ssl_context (verify = False ).get_ciphers ()]
86+
12287
12388def _is_key_file_encrypted (key_file ):
12489 """Detects if a key file is encrypted or not.
@@ -132,3 +97,9 @@ def _is_key_file_encrypted(key_file):
13297 return True
13398
13499 return False
100+
101+
102+ # We used to import the default set of TLS ciphers from urllib3, but they removed it.
103+ # Instead, now urllib3 uses the list of ciphers configured by the system.
104+ # <https://github.com/httpie/httpie/pull/1501>
105+ DEFAULT_SSL_CIPHERS_STRING = ':' .join (HTTPieHTTPSAdapter .get_default_ciphers_names ())
0 commit comments