Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect REQUESTS_CA_BUNDLE environment variable #664

Closed
thwllms opened this issue Apr 10, 2024 · 0 comments · Fixed by #669
Closed

Respect REQUESTS_CA_BUNDLE environment variable #664

thwllms opened this issue Apr 10, 2024 · 0 comments · Fixed by #669
Labels
enhancement New feature or request

Comments

@thwllms
Copy link

thwllms commented Apr 10, 2024

Sitting behind a corporate VPN/firewall which performs HTTPS inspection / SSL certificate replacement, I have to configure my environment to deal with otherwise fishy-looking certificates issued by the system. By default the basic requests.get, requests.post, etc., functions look for an environment variable REQUESTS_CA_BUNDLE (see docs), which points to a custom certificate bundle file that includes the Root CA for my company's VPN/firewall system. That one setting solves a lot of issues in Python land.

pystac-client, however, doesn't seem to respect that environment variable. It uses raw Request and Session objects to set up requests, resulting in this error:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

I think the send method call on this line should probably account for REQUESTS_CA_BUNDLE via the verify argument, something like this:

from requests import Request, Session
import os

session = Session()
request = Request(method="GET", url="https://example.com")
prepped = session.prepare_request(request)
response = session.send(prepped, verify=os.environ.get("REQUESTS_CA_BUNDLE"))
@gadomski gadomski added the enhancement New feature or request label Apr 10, 2024
@gadomski gadomski linked a pull request Apr 10, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants