The ssl module provides SSL contexts to wrap sockets in.

ssl.create_default_context() → ssl.SSLContext

Return the default SSLContext.

class ssl.SSLContext

Settings related to SSL that can be applied to a socket by wrapping it. This is useful to provide SSL certificates to specific connections rather than all of them.

ssl.wrap_socket(sock: socketpool.Socket, *, server_side: bool = False, server_hostname: str = None) → socketpool.Socket

Wraps the socket into a socket-compatible class that handles SSL negotiation. The socket must be of type SOCK_STREAM.