mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
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>
This commit is contained in:
parent
bd26ef5e9e
commit
6217864fe5
5 changed files with 109 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue