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

Verify requests with REQUESTS_CA_BUNDLE if set #665

Closed
wants to merge 3 commits into from

Conversation

thwllms
Copy link

@thwllms thwllms commented Apr 10, 2024

Related Issue(s):

Description: By default, the basic requests.get, requests.post, etc., functions look for an environment variable REQUESTS_CA_BUNDLE (see docs), which can point to a custom certificate bundle file instead of the default bundle provided with certifi. This is common practice in e.g., corporate settings where HTTPS inspection is being performed with SSL certificate replacement, causing HTTPS responses with odd-looking certificates. This PR ensures that pystac-client also respects the REQUESTS_CA_BUNDLE environment variable.

PR Checklist:

  • Code is formatted
  • Tests pass
  • Changes are added to the CHANGELOG

@gadomski gadomski linked an issue Apr 10, 2024 that may be closed by this pull request
@gadomski gadomski self-requested a review April 10, 2024 15:53
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 93.68%. Comparing base (21435b0) to head (c1a234c).
Report is 20 commits behind head on main.

Files Patch % Lines
pystac_client/stac_api_io.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #665      +/-   ##
==========================================
+ Coverage   93.43%   93.68%   +0.24%     
==========================================
  Files          13       13              
  Lines         990      997       +7     
==========================================
+ Hits          925      934       +9     
+ Misses         65       63       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thwllms
Copy link
Author

thwllms commented Apr 10, 2024

Updated to include fallback to CURL_CA_BUNDLE if REQUESTS_CA_BUNDLE isn't set, following the pattern in requests.
https://github.com/psf/requests/blob/2a438c27b5a5828c8ea0dc958112eecffca70b12/src/requests/sessions.py#L767

Copy link
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thwllms thanks for the PR! When reviewing, it felt like we should try to use requests's environment lookup if possible. I've opened #669 with an alternate solution, let me know what you think.

@thwllms
Copy link
Author

thwllms commented Apr 18, 2024

@thwllms thanks for the PR! When reviewing, it felt like we should try to use requests's environment lookup if possible. I've opened #669 with an alternate solution, let me know what you think.

Ah, I totally missed merge_environment_settings when I was going through the docs! I like that solution better. 👍

@thwllms
Copy link
Author

thwllms commented Apr 18, 2024

Closing in favor of #669

@thwllms thwllms closed this Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect REQUESTS_CA_BUNDLE environment variable
3 participants