coroutine loop.start_tls(transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None)

Upgrade an existing transport-based connection to TLS.

Return a new transport instance, that the protocol must start using immediately after the await. The transport instance passed to the start_tls method should never be used again.


  • transport and protocol instances that methods like create_server() and create_connection() return.

  • sslcontext: a configured instance of SSLContext.

  • server_side pass True when a server-side connection is being upgraded (like the one created by create_server()).

  • server_hostname: sets or overrides the host name that the target server’s certificate will be matched against.

  • ssl_handshake_timeout is (for a TLS connection) the time in seconds to wait for the TLS handshake to complete before aborting the connection. 60.0 seconds if None (default).

New in version 3.7.

Watching file descriptors

Related Reading

Event Loop