PyDocs

Nav

Networking and Interprocess Communication

SSLSocket

ssl

class (source) Deprecated 3.6not WASI
  • SSLSocket(socket.socket)
Deprecated since 3.6. It is deprecated to create a SSLSocket instance directly, use SSLContext.wrap_socket() to wrap a socket.
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.
Changed in 3.5, 3.7, 3.10, 3.15
  • 3.5: The sendfile() method was added.
  • 3.5: The shutdown() does not reset the socket timeout each time bytes are received or sent. The socket timeout is now the maximum total duration of the shutdown.
  • 3.7: SSLSocket instances must be created with wrap_socket(). In earlier versions, it was possible to create instances directly. This was never documented or officially supported.
  • 3.10: Python now uses SSL_read_ex and SSL_write_ex internally. The functions support reading and writing of data larger than 2 GB. Writing zero-length data no longer fails with a protocol violation error.
  • 3.15: Python now uses SSL_sendfile internally when possible. The function sends a file more efficiently because it performs TLS encryption in the kernel to avoid additional context switches.
Members of SSLSocket

c

cipher
Return the currently selected cipher as a 3-tuple ``(name, ssl_version, secret_bits)``.
client_sigalg
Return the selected client authentication signature algorithm.
compression
Return the current compression algorithm in use, or ``None`` if compression was not negotiated or not supported by one of the peers.
context
The SSLContext that is currently in use.

d

do_handshake
Start the SSL/TLS handshake.

g

get_channel_binding
Get channel binding data for current connection.
get_unverified_chain
Returns raw certificate chain provided by the other end of the SSL channel as a list of DER-encoded bytes.
get_verified_chain
Returns verified certificate chain provided by the other end of the SSL channel as a list of DER-encoded bytes.
getpeercert
Returns a formatted version of the data in the certificate provided by the other end of the SSL channel.
group
Return the currently selected key agreement group name.

p

pending
Return the number of bytes that can be read immediately.

r

read
Read up to LEN bytes and return them.

s

selected_alpn_protocol
Return the currently selected ALPN protocol as a string, or ``None`` if a next protocol was not negotiated or if ALPN is not supported by one of the peers.
selected_npn_protocol
Return the currently selected NPN protocol as a string, or ``None`` if a next protocol was not negotiated or if NPN is not supported by one of the peers.
server_hostname
Hostname of the server: str type, or None for server-side socket or if the hostname was not specified in the constructor.
server_side
A boolean which is True for server-side sockets and False for client-side sockets.
server_sigalg
Return the selected server handshake signature algorithm.
session
The SSLSession for client socket.
session_reused
Was the client session reused during handshake
shared_ciphers
Return a list of ciphers shared by the client during the handshake or None if this is not a valid server connection.

u

unwrap
Start the SSL shutdown handshake.

v

verify_client_post_handshake
Requests post-handshake authentication (PHA) from a TLS 1.3 client.
version
Return a string identifying the protocol version used by the current SSL channel.

w

write
Write DATA to the underlying SSL channel.
0 Examples
No examples for ssl/SSLSocket.
See Also
No see-alsos for ssl/SSLSocket
0 Notes
No notes for SSLSocket