@@ -32,7 +32,7 @@ class HTTPieCertificate(NamedTuple):
3232 def to_raw_cert (self ):
3333 """Synthesize a requests-compatible (2-item tuple of cert and key file)
3434 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
3636
3737
3838class HTTPieHTTPSAdapter (HTTPAdapter ):
@@ -48,13 +48,6 @@ def __init__(
4848 ssl_version = ssl_version ,
4949 ciphers = ciphers ,
5050 )
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 ()
5851 super ().__init__ (** kwargs )
5952
6053 def init_poolmanager (self , * args , ** kwargs ):
@@ -78,14 +71,19 @@ def _create_ssl_context(
7871 ssl_version : str = None ,
7972 ciphers : str = None ,
8073 ) -> 'ssl.SSLContext' :
81- return create_urllib3_context (
74+ context = create_urllib3_context (
8275 ciphers = ciphers ,
8376 ssl_version = resolve_ssl_version (ssl_version ),
8477 # Since we are using a custom SSL context, we need to pass this
8578 # here manually, even though it’s also passed to the connection
8679 # in `super().cert_verify()`.
8780 cert_reqs = ssl .CERT_REQUIRED if verify else ssl .CERT_NONE
8881 )
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
8987
9088 @classmethod
9189 def get_default_ciphers_names (cls ):
0 commit comments