Skip to content

Commit b1d73dd

Browse files
committed
Don't use default SSLContext with custom poolmanager kwargs
1 parent 6badbac commit b1d73dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/requests/adapters.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,20 @@ def _urllib3_request_context(
8383
request: "PreparedRequest",
8484
verify: "bool | str | None",
8585
client_cert: "typing.Tuple[str, str] | str | None",
86+
poolmanager: "PoolManager",
8687
) -> "(typing.Dict[str, typing.Any], typing.Dict[str, typing.Any])":
8788
host_params = {}
8889
pool_kwargs = {}
8990
parsed_request_url = urlparse(request.url)
9091
scheme = parsed_request_url.scheme.lower()
9192
port = parsed_request_url.port
93+
poolmanager_kwargs = getattr(poolmanager, "connection_pool_kw", {})
94+
has_poolmanager_ssl_context = poolmanager_kwargs.get("ssl_context")
95+
9296
cert_reqs = "CERT_REQUIRED"
9397
if verify is False:
9498
cert_reqs = "CERT_NONE"
95-
elif verify is True:
99+
elif verify is True and not has_poolmanager_ssl_context:
96100
pool_kwargs["ssl_context"] = _preloaded_ssl_context
97101
elif isinstance(verify, str):
98102
if not os.path.isdir(verify):
@@ -423,7 +427,7 @@ def build_connection_pool_key_attributes(self, request, verify, cert=None):
423427
portion of the Pool Key including scheme, hostname, and port. The
424428
second is a dictionary of SSLContext related parameters.
425429
"""
426-
return _urllib3_request_context(request, verify, cert)
430+
return _urllib3_request_context(request, verify, cert, self.poolmanager)
427431

428432
def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
429433
"""Returns a urllib3 connection for the given request and TLS settings.

0 commit comments

Comments
 (0)