Wrapping an existing transport in SSL
kyuupichan opened this issue · 2 comments
I hope a question is acceptable here; I've googled and not found an answer.
I want to connect to a remote Tor server listening on an SSL socket with asyncio.
I have created an asyncio SocksProtocol to handle the negotation with the local tor proxy, and this works fine to establish a connection with the remote Tor server via loop.create_connection. However that leaves me with a transport, protocol pair, and I need to wrap the transport in SSL for the app to communicate properly with the remote server.
I don't see a clean way to do this. One thing I tried was another loop.connection passing the transport's socket and an ssl arg, but that didn't work as it ends up triggering checks in asyncio because 2 transports are using the same base socket. Am I missing something obvious?
Asyncio has support for SSL itself, so instead of creating a TCP transport and then wrapping that around SSL, you could just create a SSL transport from the beginning.
That would be an SSL transport to the tor proxy, which I believe only expects TCP by default, not an SSL transport to the remote Tor server, which is the goal.