Skip to content

Commit

Permalink
fix: fix socket leak in impersonated_credentials (#1123)
Browse files Browse the repository at this point in the history
* fix: Fix socket leak in impersonated_credentials

impersonated_credentials.Credentials.sign_bytes() created
a session that wasn't closed leaking a socket. This fixes
the issue by always closing the requests session after
a signing request is complete.

Fixes #1122
  • Loading branch information
stewartmiles committed Aug 29, 2022
1 parent bb5c979 commit b1eb467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions google/auth/impersonated_credentials.py
Expand Up @@ -288,9 +288,12 @@ def sign_bytes(self, message):

authed_session = AuthorizedSession(self._source_credentials)

response = authed_session.post(
url=iam_sign_endpoint, headers=headers, json=body
)
try:
response = authed_session.post(
url=iam_sign_endpoint, headers=headers, json=body
)
finally:
authed_session.close()

if response.status_code != http_client.OK:
raise exceptions.TransportError(
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.

0 comments on commit b1eb467

Please sign in to comment.