@@ -32,7 +32,7 @@ class HTTPieCertificate(NamedTuple):
32
32
def to_raw_cert (self ):
33
33
"""Synthesize a requests-compatible (2-item tuple of cert and key file)
34
34
object from HTTPie's internal representation of a certificate."""
35
- return ( self .cert_file , self .key_file )
35
+ return self .cert_file , self .key_file
36
36
37
37
38
38
class HTTPieHTTPSAdapter (HTTPAdapter ):
@@ -48,13 +48,6 @@ def __init__(
48
48
ssl_version = ssl_version ,
49
49
ciphers = ciphers ,
50
50
)
51
- # workaround for a bug in requests 2.32.3, see:
52
- # https://github.com/httpie/cli/issues/1583
53
- if getattr (self ._ssl_context , 'load_default_certs' , None ) is not None :
54
- # if load_default_certs is present, get_ca_certs must be
55
- # also, no need for another getattr
56
- if not self ._ssl_context .get_ca_certs ():
57
- self ._ssl_context .load_default_certs ()
58
51
super ().__init__ (** kwargs )
59
52
60
53
def init_poolmanager (self , * args , ** kwargs ):
@@ -78,14 +71,19 @@ def _create_ssl_context(
78
71
ssl_version : str = None ,
79
72
ciphers : str = None ,
80
73
) -> 'ssl.SSLContext' :
81
- return create_urllib3_context (
74
+ context = create_urllib3_context (
82
75
ciphers = ciphers ,
83
76
ssl_version = resolve_ssl_version (ssl_version ),
84
77
# Since we are using a custom SSL context, we need to pass this
85
78
# here manually, even though it’s also passed to the connection
86
79
# in `super().cert_verify()`.
87
80
cert_reqs = ssl .CERT_REQUIRED if verify else ssl .CERT_NONE
88
81
)
82
+ if not context .get_ca_certs ():
83
+ # Workaround for a bug in requests 2.32.3
84
+ # See <https://github.com/httpie/cli/issues/1583>
85
+ context .load_default_certs ()
86
+ return context
89
87
90
88
@classmethod
91
89
def get_default_ciphers_names (cls ):
0 commit comments