Skip to content

Commit

Permalink
Set requests 'verify' at session level
Browse files Browse the repository at this point in the history
  • Loading branch information
thwllms committed Apr 10, 2024
1 parent d2e62fb commit 8adeabe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Updated to **pystac** v1.10.0 [#661](https://github.com/stac-utils/pystac-client/pull/661)
- Use [uv](https://github.com/astral-sh/uv) for CI [#663](https://github.com/stac-utils/pystac-client/pull/663)
- If set, use `requests`'s `REQUESTS_CA_BUNDLE` environment variable to verify HTTPS requests [#655](https://github.com/stac-utils/pystac-client/pull/665)
- If set, use `requests`'s `REQUESTS_CA_BUNDLE` environment variable and `CURL_CA_BUNDLE` fallback to verify HTTPS requests [#655](https://github.com/stac-utils/pystac-client/pull/665)

## [v0.7.6]

Expand Down
11 changes: 4 additions & 7 deletions pystac_client/stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

Timeout = Union[float, Tuple[float, float], Tuple[float, None]]

REQUESTS_CA_BUNDLE = os.environ.get("REQUESTS_CA_BUNDLE")
CA_BUNDLE = os.environ.get("REQUESTS_CA_BUNDLE") or os.environ.get("CURL_CA_BUNDLE")


class StacApiIO(DefaultStacIO):
Expand Down Expand Up @@ -97,6 +97,8 @@ def __init__(
if max_retries:
self.session.mount("http://", HTTPAdapter(max_retries=max_retries))
self.session.mount("https://", HTTPAdapter(max_retries=max_retries))
if CA_BUNDLE:
self.session.verify = CA_BUNDLE
self.timeout = timeout
self.update(
headers=headers, parameters=parameters, request_modifier=request_modifier
Expand Down Expand Up @@ -212,12 +214,7 @@ def request(
if self.timeout is not None:
msg += f" Timeout: {self.timeout}"
logger.debug(msg)
if REQUESTS_CA_BUNDLE:
resp = self.session.send(
prepped, timeout=self.timeout, verify=REQUESTS_CA_BUNDLE
)
else:
resp = self.session.send(prepped, timeout=self.timeout)
resp = self.session.send(prepped, timeout=self.timeout)
except Exception as err:
logger.debug(err)
raise APIError(str(err))
Expand Down

0 comments on commit 8adeabe

Please sign in to comment.