Skip to content

Commit

Permalink
fix(auth): correctly set ssl flag for aio
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-johnston committed Dec 7, 2023
1 parent 1393b37 commit c799876
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion auth/gcloud/aio/auth/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,19 @@ class AioSession(BaseSession):
_session: aiohttp.ClientSession # type: ignore[assignment]
_timeout: Timeout # type: ignore[assignment]

# N.B. `aiohttp.TCPConnector` SSL config is not true / false / CA
# bundle path like `requests`, but `None` / false / object instead:
# * `None` for default SSL check
# * `False` to skip SSL certificate validation
# * `aiohttp.Fingerprint` for fingerprint validation
# * `ssl.SSLContext` for custom SSL certificate validation
#
# https://docs.aiohttp.org/en/v3.9.1/client_reference.html#aiohttp.TCPConnector
@property
def session(self) -> aiohttp.ClientSession: # type: ignore[override]
if not self._session:
connector = aiohttp.TCPConnector(ssl=self._ssl)
connector = aiohttp.TCPConnector(
ssl=None if self._ssl else False)

if isinstance(self._timeout, aiohttp.ClientTimeout):
timeout = self._timeout
Expand Down

0 comments on commit c799876

Please sign in to comment.