PyDocs

Nav

Networking and Interprocess Communication

SSLContext.wrap_socket

ssl

method of SSLContext (source) not WASI
  • SSLContext.wrap_socket(sock, server_side=False, do_handshake_on_connect=True, suppress_ragged_eofs=True, server_hostname=None, session=None)
Wrap an existing Python socket sock and return an instance of SSLContext.sslsocket_class (default SSLSocket). The returned SSL socket is tied to the context, its settings and certificates. sock must be a SOCK_STREAM socket; other socket types are unsupported.
Changed in 3.5, 3.6, 3.7
  • 3.5: Always allow a server_hostname to be passed, even if OpenSSL does not have SNI.
  • 3.6: session argument was added.
  • 3.7: The method returns an instance of SSLContext.sslsocket_class instead of hard-coded SSLSocket.
1 Example
>>> conn = context.wrap_socket(socket.socket(socket.AF_INET),
...                            server_hostname="www.python.org")
>>> conn.connect(("www.python.org", 443))
from the Python docs
See Also
No see-alsos for ssl/SSLContext.wrap_socket
0 Notes
No notes for SSLContext.wrap_socket