Skip to content

Commit

Permalink
Verify requests with REQUESTS_CA_BUNDLE if set
Browse files Browse the repository at this point in the history
  • Loading branch information
thwllms committed Apr 10, 2024
1 parent fa4206f commit c1a234c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pystac_client/stac_api_io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import os
import warnings
from copy import deepcopy
from typing import (
Expand Down Expand Up @@ -41,6 +42,8 @@

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

REQUESTS_CA_BUNDLE = os.environ.get("REQUESTS_CA_BUNDLE")


class StacApiIO(DefaultStacIO):
def __init__(
Expand Down Expand Up @@ -209,7 +212,12 @@ def request(
if self.timeout is not None:
msg += f" Timeout: {self.timeout}"
logger.debug(msg)
resp = self.session.send(prepped, timeout=self.timeout)
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)
except Exception as err:
logger.debug(err)
raise APIError(str(err))
Expand Down

0 comments on commit c1a234c

Please sign in to comment.