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

bpo-37179: Support asyncio loop.start_tls() for TLS in TLS #28073

Closed
wants to merge 3 commits into from

Conversation

jborean93
Copy link
Contributor

Adds the _start_tls_compatible attribute that start_tls checks. This is required to support using a HTTPS proxy when targeting a HTTPS endpoint.

This is my first PR to CPython so I'm unsure what the full process is, let me know if there is anything I'm missing.

https://bugs.python.org/issue37179

@webknjaz
Copy link
Contributor

webknjaz commented Sep 9, 2021

@asvetlov could you please review this PR from my colleague? 🙏

It also looks like this may help aiohttp gain support for proxying TLS-in-TLS too.

@webknjaz
Copy link
Contributor

@tiran maybe you could help?

webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* aio-libs#5992

Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* aio-libs#5992

Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* aio-libs#5992

Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* aio-libs#5992

Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz pushed a commit to aio-libs/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.
    
Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* #5992

Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>

PR #6002
webknjaz pushed a commit to webknjaz/aiohttp that referenced this pull request Oct 3, 2021
This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* aio-libs#5992

Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>

PR aio-libs#6002

(cherry picked from commit d66e07c)
webknjaz added a commit to aio-libs/aiohttp that referenced this pull request Oct 3, 2021
…nst ``proxy.py`` (#6033)

This patch adds full end-to-end tests for sending requests to HTTP and
HTTPS endpoints through an HTTPS proxy. The first case is currently
supported and the second one is not. This is why the latter test is
marked as expected to fail. The support for TLS-in-TLS in the upstream
stdlib asyncio is currently disabled but is available in Python 3.9
via monkey-patching which is demonstrated in the added tests.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* #5992

Co-authored-by: bmbouter <bmbouter@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>

PR #6002

(cherry picked from commit d66e07c)
webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 5, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

Resolves aio-libs#3816
Resolves aio-libs#4268

Co-Authored-By: Brian Bouterse <bmbouter@gmail.com>
Co-Authored-By: Jordan Borean <jborean93@gmail.com>
Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz added a commit to bmbouter/aiohttp that referenced this pull request Oct 5, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

Resolves aio-libs#3816
Resolves aio-libs#4268

Co-Authored-By: Brian Bouterse <bmbouter@gmail.com>
Co-Authored-By: Jordan Borean <jborean93@gmail.com>
Co-Authored-By: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz added a commit to aio-libs/aiohttp that referenced this pull request Oct 5, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* #6044

PR #5992
Resolves #3816
Resolves #4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
webknjaz pushed a commit to webknjaz/aiohttp that referenced this pull request Oct 5, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

PR aio-libs#5992
Resolves aio-libs#3816
Resolves aio-libs#4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
(cherry picked from commit c29e5fb)
webknjaz pushed a commit to webknjaz/aiohttp that referenced this pull request Oct 5, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

PR aio-libs#5992
Resolves aio-libs#3816
Resolves aio-libs#4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
(cherry picked from commit c29e5fb)
webknjaz pushed a commit to webknjaz/aiohttp that referenced this pull request Oct 11, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

PR aio-libs#5992
Resolves aio-libs#3816
Resolves aio-libs#4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
(cherry picked from commit c29e5fb)
webknjaz pushed a commit to webknjaz/aiohttp that referenced this pull request Oct 12, 2021
This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* https://bugs.python.org/issue37179
* python/cpython#28073
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* aio-libs#6044

PR aio-libs#5992
Resolves aio-libs#3816
Resolves aio-libs#4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
(cherry picked from commit c29e5fb)
webknjaz added a commit to aio-libs/aiohttp that referenced this pull request Oct 12, 2021
…ent (#6049)

This patch opens up the code path and adds the implementation that
allows end-users to start sending HTTPS requests through
HTTPS proxies.

The support for TLS-in-TLS (needed for this to work) in the stdlib is
kinda available since Python 3.7 but is disabled for `asyncio` with an
attribute/flag/toggle. When the upstream CPython enables it finally,
aiohttp v3.8+ will be able to work with it out of the box.

Currently the tests monkey-patch `asyncio` in order to verify that
this works. The users who are willing to do the same, will be able to
take advantage of it right now. Eventually (hopefully starting Python
3.11), the need for monkey-patching should be eliminated.

Refs:
* bugs.python.org/issue37179
* python/cpython#28073
* docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* #6044

PR #5992
Resolves #3816
Resolves #4268

Co-authored-by: Brian Bouterse <bmbouter@gmail.com>
Co-authored-by: Jordan Borean <jborean93@gmail.com>
Co-authored-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
@jborean93
Copy link
Contributor Author

I've been trying to solve the test failures on Windows and I think I've found the underlying problem. The current tests have the server sending the shutdown signal on the inner TLS layer which is received by the client. When processed by the client the SSLProtocol is closing the outer protocols and due to how the code is set up the outer TLS layer is being closed before the inner one. More work is most likely needed to solve this problem.

@asvetlov asvetlov closed this Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants