◐ Shell
clean mode source ↗

bpo-34975: Add start_tls() method to streams API by icgood · Pull Request #13143 · python/cpython

Conversation

@icgood

The existing event loop start_tls() method is not sufficient for
connections using the streams API. The existing StreamReader works
because the new transport passes received data to the original protocol.
The StreamWriter must then write data to the new transport, and the
StreamReaderProtocol must be updated to close the new transport
correctly.

The new StreamWriter start_tls() updates itself and the reader
protocol to the new SSL transport.

https://bugs.python.org/issue34975

The existing event loop `start_tls()` method is not sufficient for
connections using the streams API. The existing StreamReader works
because the new transport passes received data to the original protocol.
The StreamWriter must then write data to the new transport, and the
StreamReaderProtocol must be updated to close the new transport
correctly.

The new StreamWriter `start_tls()` updates itself and the reader
protocol to the new SSL transport.

@asvetlov

@arhadthedev

@asvetlov Can this PR be reopened? #13251 got refused and was reverted by #16482 with the following explainer in bpo-38242:

The asyncio.Stream class we have now is overloaded with functionality. It's not composable. It's internal buffer and APIs are designed to parsing text protocols (i.e. parsing a complex binary protocol requires an entirely different buffer implementation).

I'm bringing this PR up because I need to port test.test_poplib and test.test_ftplib from to-be-removed asynchat and they use on-demand switching from plain text to SSL and back.

@icgood Could you also add stop_tls() to match start_tls(), please?

@icgood

@icgood icgood mannequin mentioned this pull request

May 20, 2022

@1st1 1st1 mentioned this pull request

Dec 28, 2022

Labels