Skip to content
Myr

Don't use default SSLContext with custom poolmanager kwargs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by Nate Prewitt · parent 6badbac · Browse files · 1 file+6 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−2 removed

  • other:+6 added−2 removed

1 file+6 added−2 removed

modified:src/requests/adapters.py+6 added-2 removed
81 unmodified lines
82def _urllib3_request_context(83 request: "PreparedRequest",84 verify: "bool | str | None",85 client_cert: "typing.Tuple[str, str] | str | None",86 poolmanager: "PoolManager",87) -> "(typing.Dict[str, typing.Any], typing.Dict[str, typing.Any])":88 host_params = {}89 pool_kwargs = {}90 parsed_request_url = urlparse(request.url)91 scheme = parsed_request_url.scheme.lower()92 port = parsed_request_url.port93 poolmanager_kwargs = getattr(poolmanager, "connection_pool_kw", {})94 has_poolmanager_ssl_context = poolmanager_kwargs.get("ssl_context")9596 cert_reqs = "CERT_REQUIRED"97 if verify is False:98 cert_reqs = "CERT_NONE"95 elif verify is True:99 elif verify is True and not has_poolmanager_ssl_context:100 pool_kwargs["ssl_context"] = _preloaded_ssl_context101 elif isinstance(verify, str):102 if not os.path.isdir(verify):103 pool_kwargs["ca_certs"] = verify
322 unmodified lines
426 A tuple of two dictionaries. The first is the "host parameters"427 portion of the Pool Key including scheme, hostname, and port. The428 second is a dictionary of SSLContext related parameters.429 """426 return _urllib3_request_context(request, verify, cert)430 return _urllib3_request_context(request, verify, cert, self.poolmanager)431432 def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):433 """Returns a urllib3 connection for the given request and TLS settings.434 This should not be called from user code, and is only exposed for use
271 unmodified lines