Skip to content

How to send an HTTPS query through an HTTPS proxy with aiohttp v3.8? #6044

Answered by webknjaz
webknjaz asked this question in Q&A
Discussion options

You must be logged in to vote

The asyncio.loop.start_tls() is available since Python 3.7. But some of the asyncio internals don't set an attribute that would enable creating TLS connections encapsulated inside of other TLS connections (at least, not until Python 3.11).

It is possible to patch the stdlib asyncio to allow this. Add the following monkey-patch in your app and it will work (to the extent of what CPython itself supports):

import asyncio

setattr(asyncio.sslproto._SSLProtocolTransport, "_start_tls_compatible", True)

After this, proceed using the proxy as normal. Here's the doc: https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support.

Note that this support has only been enabled on the aiohttp s…

Replies: 7 comments 11 replies

Comment options

webknjaz
Oct 5, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by webknjaz
Comment options

You must be logged in to vote
4 replies
@webknjaz
Comment options

webknjaz Sep 22, 2022
Maintainer Author

@NewUserHa
Comment options

@Dreamsorcerer
Comment options

@NewUserHa
Comment options

Comment options

You must be logged in to vote
3 replies
@webknjaz
Comment options

webknjaz Oct 4, 2022
Maintainer Author

@danmarinescu
Comment options

@3awny
Comment options

This comment was marked as off-topic.

@sergenti

This comment was marked as off-topic.

Comment options

You must be logged in to vote
2 replies
@sergenti

This comment was marked as off-topic.

@webknjaz
Comment options

webknjaz Apr 1, 2024
Maintainer Author

This comment has been minimized.

Comment options

You must be logged in to vote
1 reply
@webknjaz
Comment options

webknjaz Apr 1, 2024
Maintainer Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants