diff options
author | Oleg Iarygin <oleg@arhadthedev.net> | 2022-04-15 12:23:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-15 12:23:14 (GMT) |
commit | 6217864fe5f6855f59d608733ce83fd4466e1b8c (patch) | |
tree | 3d852fadd0e29891d382ed9f41f161b237b3e703 /Doc | |
parent | bd26ef5e9e701d2ab3509a49d9351259a3670772 (diff) | |
download | cpython-6217864fe5f6855f59d608733ce83fd4466e1b8c.zip cpython-6217864fe5f6855f59d608733ce83fd4466e1b8c.tar.gz cpython-6217864fe5f6855f59d608733ce83fd4466e1b8c.tar.bz2 |
gh-79156: Add start_tls() method to streams API (#91453)
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.
Co-authored-by: Ian Good <icgood@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/asyncio-stream.rst | 18 | ||||
-rw-r--r-- | Doc/whatsnew/3.11.rst | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst index ba534f9..72355d3 100644 --- a/Doc/library/asyncio-stream.rst +++ b/Doc/library/asyncio-stream.rst @@ -295,6 +295,24 @@ StreamWriter be resumed. When there is nothing to wait for, the :meth:`drain` returns immediately. + .. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \ + ssl_handshake_timeout=None) + + Upgrade an existing stream-based connection to TLS. + + Parameters: + + * *sslcontext*: a configured instance of :class:`~ssl.SSLContext`. + + * *server_hostname*: sets or overrides the host name that the target + server's certificate will be matched against. + + * *ssl_handshake_timeout* is the time in seconds to wait for the TLS + handshake to complete before aborting the connection. ``60.0`` seconds + if ``None`` (default). + + .. versionadded:: 3.8 + .. method:: is_closing() Return ``True`` if the stream is closed or in the process of diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst index dba554c..9f7f6f5 100644 --- a/Doc/whatsnew/3.11.rst +++ b/Doc/whatsnew/3.11.rst @@ -246,6 +246,10 @@ asyncio :meth:`~asyncio.AbstractEventLoop.sock_recvfrom_into`. (Contributed by Alex Grönholm in :issue:`46805`.) +* Add :meth:`~asyncio.streams.StreamWriter.start_tls` method for upgrading + existing stream-based connections to TLS. (Contributed by Ian Good in + :issue:`34975`.) + fractions --------- |