ssl.SSLSocket

class ssl.SSLSocket(sock=None, keyfile=None, certfile=None, server_side=False, cert_reqs=0, ssl_version=2, ca_certs=None, do_handshake_on_connect=True, family=2, type=1, proto=0, fileno=None, suppress_ragged_eofs=True, npn_protocols=None, ciphers=None, server_hostname=None, _context=None)[source]

This class implements a subtype of socket.socket that wraps the underlying OS socket in an SSL context when necessary, and provides read and write methods over that channel.

Methods

__format__ default object formatter
__init__([sock, keyfile, certfile, ...])
__new__((S, ...)
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__sizeof__(() -> int) size of object in memory, in bytes
__subclasshook__ Abstract classes can override this to customize issubclass().
_checkClosed([msg])
_check_connected()
_real_close()
_real_connect(addr, connect_ex)
accept() Accepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.
bind(address) Bind the socket to a local address.
cipher()
close()
compression()
connect(addr) Connects to remote ADDR, and then wraps the connection in an SSL channel.
connect_ex(addr) Connects to remote ADDR, and then wraps the connection in an SSL channel.
do_handshake([block]) Perform a TLS/SSL handshake.
dup()
fileno(() -> integer) Return the integer file descriptor of the socket.
get_channel_binding([cb_type]) Get channel binding data for current connection.
getpeercert([binary_form]) Returns a formatted version of the data in the certificate provided by the other end of the SSL channel.
getpeername(() -> address info) Return the address of the remote endpoint.
getsockname(() -> address info) Return the address of the local endpoint.
getsockopt((level, option[, ...) Get a socket option.
gettimeout(() -> timeout) Returns the timeout in seconds (float) associated with socket operations.
listen(backlog) Enable a server to accept connections.
makefile([mode, bufsize]) Make and return a file-like object that works with the SSL connection.
pending()
read([len, buffer]) Read up to LEN bytes and return them.
recv([buflen, flags])
recv_into(buffer[, nbytes, flags])
recvfrom([buflen, flags])
recvfrom_into(buffer[, nbytes, flags])
selected_alpn_protocol()
selected_npn_protocol()
send(data[, flags])
sendall(data[, flags])
sendto(data, flags_or_addr[, addr])
setblocking(flag) Set the socket to blocking (flag is true) or non-blocking (false).
setsockopt(level, option, value) Set a socket option.
settimeout(timeout) Set a timeout on socket operations.
shutdown(how)
unwrap()
version() Return a string identifying the protocol version used by the current SSL channel, or None if there is no established channel.
write(data) Write DATA to the underlying SSL channel.

Attributes

context
family the socket family
proto the socket protocol
type the socket type