[New-bugs-announce] [issue34975] start_tls() difficult when using asyncio.start_server()
Ian Good
report at bugs.python.org
Sat Oct 13 16:03:13 EDT 2018
New submission from Ian Good <icgood at gmail.com>:
There does not seem to be a public API for replacing the transport of the StreamReader / StreamWriter provided to the callback of a call to asyncio.start_server().
The only way I have found to use the new SSL transport is to update protected members of the StreamReaderProtocol object, e.g.:
async def callback(reader, writer):
loop = asyncio.get_event_loop()
transport = writer.transport
protocol = transport.get_protocol()
new_transport = await loop.start_tls(
transport, protocol, ssl_context, server_side=True)
protocol._stream_reader = StreamReader(loop=loop)
protocol._client_connected_cb = do_stuff_after_start_tls
protocol.connection_made(new_transport)
async def do_stuff_after_start_tls(ssl_reader, ssl_writer): ...
----------
components: asyncio
messages: 327665
nosy: asvetlov, icgood, yselivanov
priority: normal
severity: normal
status: open
title: start_tls() difficult when using asyncio.start_server()
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34975>
_______________________________________
More information about the New-bugs-announce
mailing list