@@ -108,7 +108,7 @@ def __init__(
108
108
self .enable_gzip_compression = enable_gzip_compression
109
109
self ._set_user_agent_header (self ._build_user_agent ())
110
110
self .retry_config = None
111
- self .http_adapter = SSLHTTPAdapter ()
111
+ self .http_adapter = SSLHTTPAdapter (_disable_ssl_verification = self . disable_ssl_verification )
112
112
if not self .authenticator :
113
113
raise ValueError ('authenticator must be provided' )
114
114
if not isinstance (self .authenticator , Authenticator ):
@@ -138,14 +138,16 @@ def enable_retries(self, max_retries: int = 4, retry_interval: float = 30.0) ->
138
138
# Omitting this will default to all methods except POST
139
139
allowed_methods = ['HEAD' , 'GET' , 'PUT' , 'DELETE' , 'OPTIONS' , 'TRACE' , 'POST' ],
140
140
)
141
- self .http_adapter = SSLHTTPAdapter (max_retries = self .retry_config )
141
+ self .http_adapter = SSLHTTPAdapter (
142
+ max_retries = self .retry_config , _disable_ssl_verification = self .disable_ssl_verification
143
+ )
142
144
self .http_client .mount ('http://' , self .http_adapter )
143
145
self .http_client .mount ('https://' , self .http_adapter )
144
146
145
147
def disable_retries (self ):
146
148
"""Remove retry config from http_adapter"""
147
149
self .retry_config = None
148
- self .http_adapter = SSLHTTPAdapter ()
150
+ self .http_adapter = SSLHTTPAdapter (_disable_ssl_verification = self . disable_ssl_verification )
149
151
self .http_client .mount ('http://' , self .http_adapter )
150
152
self .http_client .mount ('https://' , self .http_adapter )
151
153
@@ -223,8 +225,18 @@ def set_disable_ssl_verification(self, status: bool = False) -> None:
223
225
Keyword Arguments:
224
226
status: set to true to disable ssl verification (default: {False})
225
227
"""
228
+ if self .disable_ssl_verification == status :
229
+ # Do nothing if the state doesn't change.
230
+ return
231
+
226
232
self .disable_ssl_verification = status
227
233
234
+ self .http_adapter = SSLHTTPAdapter (
235
+ max_retries = self .retry_config , _disable_ssl_verification = self .disable_ssl_verification
236
+ )
237
+ self .http_client .mount ('http://' , self .http_adapter )
238
+ self .http_client .mount ('https://' , self .http_adapter )
239
+
228
240
def set_service_url (self , service_url : str ) -> None :
229
241
"""Set the url the service will make HTTP requests too.
230
242
0 commit comments