Skip to content

Commit

Permalink
Allow loading CA certificates from memory for proxies (#3150)
Browse files Browse the repository at this point in the history
Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
  • Loading branch information
ravi-kale and illia-v committed Nov 3, 2023
1 parent b99cc39 commit ff764a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/3065.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixed an issue where it was not possible to pass the ca_cert_data keyword argument in a proxy context when making SSL
requests. Previously, attempting to pass ca_cert_data in a proxy context would result in an error.
This issue has been resolved, and users can now pass ca_cert_data when making SSL requests through a proxy context.
2 changes: 2 additions & 0 deletions src/urllib3/poolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"cert_file",
"cert_reqs",
"ca_certs",
"ca_cert_data",
"ssl_version",
"ssl_minimum_version",
"ssl_maximum_version",
Expand Down Expand Up @@ -73,6 +74,7 @@ class PoolKey(typing.NamedTuple):
key_cert_file: str | None
key_cert_reqs: str | None
key_ca_certs: str | None
key_ca_cert_data: str | bytes | None
key_ssl_version: int | str | None
key_ssl_minimum_version: ssl.TLSVersion | None
key_ssl_maximum_version: ssl.TLSVersion | None
Expand Down
10 changes: 10 additions & 0 deletions test/with_dummyserver/test_proxy_poolmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ def test_https_proxy(self) -> None:
r = https.request("GET", f"{self.http_url}/")
assert r.status == 200

def test_http_and_https_kwarg_ca_cert_data_proxy(self) -> None:
with open(DEFAULT_CA) as pem_file:
pem_file_data = pem_file.read()
with proxy_from_url(self.https_proxy_url, ca_cert_data=pem_file_data) as https:
r = https.request("GET", f"{self.https_url}/")
assert r.status == 200

r = https.request("GET", f"{self.http_url}/")
assert r.status == 200

def test_https_proxy_with_proxy_ssl_context(self) -> None:
proxy_ssl_context = create_urllib3_context()
proxy_ssl_context.load_verify_locations(DEFAULT_CA)
Expand Down

0 comments on commit ff764a0

Please sign in to comment.