auth: get_client_cert_and_key() suppresses default SSL fallback on empty callback
@agrawalradhika-cell がすでに取り組んでいます。
2026年9月8日 から。
評価
この issue はまだ評価されていません。
説明
In google.auth.aio.transport.mtls.get_client_cert_and_key(), providing a client_cert_callback causes the function to return (True, cert, key) unconditionally. When the callback returns (None, None) or empty bytes, the function returns (True, None, None).
This violates the documented contract:
"if the callback is None or doesn't provide certificate and key, the function tries application default SSL credentials"
Because line 176 returns early, execution never falls through to await get_client_ssl_credentials(). Downstream callers such as AsyncAuthorizedSession.configure_mtls_channel() receive has_cert = True and set self._is_mtls = True, but passing (None, None) into make_client_cert_ssl_context() skips load_cert_chain() and returns an SSL context without client certificates while the session treats mTLS as active.
The synchronous implementation in google.auth.transport._mtls_helper.get_client_cert_and_key() shares this same behavior.
Proposed Fix
Guard the callback return value to ensure cert and key are truthy before returning has_cert = True:
if client_cert_callback:
result = client_cert_callback()
if inspect.isawaitable(result):
cert, key = await result
else:
cert, key = result
if cert and key:
return True, cert, key
has_cert, cert, key, _ = await get_client_ssl_credentials()
return has_cert, cert, key
The corresponding guard should be applied to google.auth.transport._mtls_helper.get_client_cert_and_key(). Unit tests in tests/transport/aio/test_aio_mtls_helper.py and tests/transport/test__mtls_helper.py should assert that callbacks returning (None, None) fall back to default SSL credentials when available, or return (False, None, None) when no credentials exist.
- 主要言語
- Python
- スター
- 5.4k
- フォーク
- 1.8k
- 平均マージ
- 2日 22時間
- マージ済み PR(30日)
- 102
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
googleapis/google-cloud-python#18428 ·
-
priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
googleapis/google-cloud-python#18375 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
googleapis/google-cloud-python#18339 ·
-
auth priority: p2
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
googleapis/google-cloud-python#18315 ·
-
priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
googleapis/google-cloud-python#18260 ·
googleapis/google-cloud-python の issue をすべて見る
似ている issue
-
link-check link-check:sphinx-theme
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
CSCfi/sd-search-api#39 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100