Repository navigation
[python] honor assert_hostname in the asyncio and httpx clients - #25796
Open
Yohan-Senadheera wants to merge 1 commit into
Open
Yohan-Senadheera wants to merge 1 commit into
Yohan-Senadheera wants to merge 1 commit into
Conversation
The urllib3 client passes Configuration.assert_hostname to the pool manager, but the asyncio (aiohttp) and httpx clients never read it, so assert_hostname=False has no effect there. Set ssl_context.check_hostname from it when verify_ssl is on. With verify_ssl off it is left alone, so certificate verification is not switched back on. Signed-off-by: Yohan Senadheera <yohansenadheera@gmail.com>
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The urllib3 client passes
Configuration.assert_hostnameto the pool manager, but the asyncio (aiohttp) and httpx clients never read it, soassert_hostname=Falsehas no effect there.This sets
ssl_context.check_hostnamefrom it whenverify_sslis on. Withverify_ssloff it is left alone, so certificate verification is not switched back on.Context: the Kubernetes Python client hit this in its asyncio client (kubernetes-client/python#2795). The maintainers asked for the fix here in the generator rather than as a post-processing patch (kubernetes-client/gen#314).
Changes:
python/asyncio/rest.mustacheandpython/httpx/rest.mustacherest.pyin the python-aiohttp, python-httpx, python-httpx-sync, python-httpx2 and python-httpx2-sync samplesTestAssertHostname): they fail on master and pass with this change. The rest of each sample suite is unchanged (the pet API tests need a running petstore server).PR checklist
batch bin/configs/<config>.yaml); the generatedrest.pyfiles match the committed ones exactly. Onlyrest.mustachechanged, so no other generated file is affected.Summary by cubic
Honors
assert_hostnamein the asyncio (aiohttp) and httpx clients soassert_hostname=Falsedisables hostname checks there, matching the urllib3 client. This fixes the Kubernetes Python client's asyncio client (kubernetes-client/python#2795). Hostname checking is only applied whenverify_sslis on, so disabling verification never re-enables it.Written for commit 2d4776a. Summary will update on new commits.