summaryrefslogtreecommitdiff
path: root/net-misc/httpie/files/httpie-urllib3-2-fixes.patch
blob: 2c6c5d3481714c9e7fbc00ca5bd62177a69a297d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From f8bb34ebf97bf6a103a7d021b16059522d76d52d Mon Sep 17 00:00:00 2001
From: Brendon Smith <bws@bws.bio>
Date: Sat, 6 May 2023 16:24:26 -0400
Subject: [PATCH] Fix `urllib3.util.ssl_.DEFAULT_CIPHERS` import

---
 httpie/cli/definition.py |  4 ++--
 httpie/ssl_.py           | 15 ++++++++++-----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/httpie/cli/definition.py b/httpie/cli/definition.py
index 0e5f91edf7..5e54d1c896 100644
--- a/httpie/cli/definition.py
+++ b/httpie/cli/definition.py
@@ -831,8 +831,8 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
     short_help='A string in the OpenSSL cipher list format.',
     help=f"""
 
-    A string in the OpenSSL cipher list format. By default, the following
-    is used:
+    A string in the OpenSSL cipher list format. By default, the available
+    system ciphers will be used, which are:
 
     {DEFAULT_SSL_CIPHERS}
 
diff --git a/httpie/ssl_.py b/httpie/ssl_.py
index b9438543eb..c8dba0ea8d 100644
--- a/httpie/ssl_.py
+++ b/httpie/ssl_.py
@@ -3,13 +3,9 @@
 
 from httpie.adapters import HTTPAdapter
 # noinspection PyPackageRequirements
-from urllib3.util.ssl_ import (
-    DEFAULT_CIPHERS, create_urllib3_context,
-    resolve_ssl_version,
-)
+from urllib3.util.ssl_ import create_urllib3_context, resolve_ssl_version
 
 
-DEFAULT_SSL_CIPHERS = DEFAULT_CIPHERS
 SSL_VERSION_ARG_MAPPING = {
     'ssl2.3': 'PROTOCOL_SSLv23',
     'ssl3': 'PROTOCOL_SSLv3',
@@ -94,3 +90,12 @@ def _is_key_file_encrypted(key_file):
                 return True
 
     return False
+
+
+try:
+    from urllib3.util.ssl_ import DEFAULT_CIPHERS
+except ImportError:
+    _context = HTTPieHTTPSAdapter._create_ssl_context(verify=False)
+    DEFAULT_CIPHERS = ":".join([cipher["name"] for cipher in _context.get_ciphers()])
+
+DEFAULT_SSL_CIPHERS = DEFAULT_CIPHERS