Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing a custom server name parameter on HTTPS connection #7543

Conversation

multani
Copy link
Contributor

@multani multani commented Aug 20, 2023

This adds the missing support to set the server_hostname setting when creating TCP connection, when the underlying connection is authenticated using TLS.

See the documentation for the 2 stdlib functions:

This would be needed to support features in clients using aiohttp, such as tomplus/kubernetes_asyncio#267

The default behavior should not change, but this would allow on a per-connection basis to specify a custom server name to check the certificate name against.

Closes: #7114

Backport of #7541 to 3.9

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
  • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following: * .feature: Signifying a new feature. * .bugfix: Signifying a bug fix. * .doc: Signifying a documentation improvement. * .removal: Signifying a deprecation or removal of public API.
  • .misc: A ticket has been closed, but it is not of interest to users.
  • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sam Bull aa6bs0@sambull.org
(cherry picked from commit ac29dea)

…io-libs#7541)

This adds the missing support to set the `server_hostname` setting when
creating TCP connection, when the underlying connection is authenticated
using TLS.

See the documentation for the 2 stdlib functions:

*
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_connection
*
https://docs.python.org/3/library/asyncio-eventloop.html#opening-network-connections

This would be needed to support features in clients using aiohttp, such
as tomplus/kubernetes_asyncio#267

The default behavior should not change, but this would allow on a
per-connection basis to specify a custom server name to check the
certificate name against.

Closes: aio-libs#7114

(for reference, similar implementation in urllib3:
urllib3/urllib3#1397)

- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes
- [x] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
  * The format is &lt;Name&gt; &lt;Surname&gt;.
  * Please keep alphabetical order, the file is sorted by names.
- [x] Add a new news fragment into the `CHANGES` folder
  * name it `<issue_id>.<type>` for example (588.bugfix)
* if you don't have an `issue_id` change it to the pr id after creating
the pr
  * ensure type is one of the following:
    * `.feature`: Signifying a new feature.
    * `.bugfix`: Signifying a bug fix.
    * `.doc`: Signifying a documentation improvement.
    * `.removal`: Signifying a deprecation or removal of public API.
* `.misc`: A ticket has been closed, but it is not of interest to users.
* Make sure to use full sentences with correct case and punctuation, for
example: "Fix issue with non-ascii contents in doctest text files."

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
(cherry picked from commit ac29dea)
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Aug 20, 2023
@Dreamsorcerer Dreamsorcerer enabled auto-merge (squash) August 20, 2023 21:06
@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

Merging #7543 (7d7aef1) into 3.9 (bdeca03) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##              3.9    #7543   +/-   ##
=======================================
  Coverage   97.29%   97.30%           
=======================================
  Files         107      107           
  Lines       31628    31685   +57     
  Branches     3661     3667    +6     
=======================================
+ Hits        30773    30830   +57     
  Misses        651      651           
  Partials      204      204           
Flag Coverage Δ
CI-GHA 97.24% <100.00%> (+<0.01%) ⬆️
OS-Linux 96.93% <100.00%> (+<0.01%) ⬆️
OS-Windows 94.43% <36.84%> (-0.11%) ⬇️
OS-macOS 96.60% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 94.34% <36.84%> (-0.11%) ⬇️
Py-3.10.12 96.80% <100.00%> (+<0.01%) ⬆️
Py-3.11.4 96.51% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 94.32% <36.84%> (-0.11%) ⬇️
Py-3.8.17 96.74% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 94.32% <36.84%> (-0.11%) ⬇️
Py-3.9.17 96.78% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.11 96.31% <100.00%> (+0.01%) ⬆️
VM-macos 96.60% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 96.93% <100.00%> (+<0.01%) ⬆️
VM-windows 94.43% <36.84%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
aiohttp/client.py 94.88% <ø> (ø)
aiohttp/client_reqrep.py 97.84% <100.00%> (+<0.01%) ⬆️
aiohttp/connector.py 92.54% <100.00%> (+0.01%) ⬆️
tests/test_connector.py 97.75% <100.00%> (+0.02%) ⬆️
tests/test_proxy.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Dreamsorcerer Dreamsorcerer merged commit f5b2f3d into aio-libs:3.9 Aug 20, 2023
23 of 28 checks passed
@multani multani deleted the patchback/backports/3.9/ac29dea2c6a01d718677bd26fcd09e847785d89f/pr-7541 branch August 20, 2023 21:27
@multani
Copy link
Contributor Author

multani commented Aug 21, 2023

@Dreamsorcerer Do you think it would be possible to get a new 3.9 release with this fix?

@Dreamsorcerer
Copy link
Member

Had a couple of other priorities, but will get back to a 3.9 release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants