SSL¶
An SSL session manages handshakes, encryption and decryption. It is not tied to any transport layer.
Public Functions¶
alpn_selected¶
The protocol identifier negotiated via ALPN, or None when no protocol
has been selected.
Returns¶
- (ALPNProtocolName | None val)
close¶
Send close_notify to the peer, initiating an orderly TLS shutdown.
After calling this, drain send to deliver the encrypted close_notify
bytes to the transport. Does nothing when the session is not ready or
has already been closed.
A graceful socket close finishes queued writes first, then calls close,
drains send, and calls dispose when done. A hard close skips close
and calls dispose directly.
Returns¶
- None val
read¶
Returns unencrypted bytes to be passed to the application, None when
no data is available yet, SSLClosed when the peer sent close_notify,
or SSLError on a protocol or I/O error.
When expect is non-zero, buffers internally until at least expect
bytes are available, then returns everything it holds.
Parameters¶
- expect: USize val = 0
Returns¶
write¶
Encrypt application data for sending. Raises an error when the session is not ready for application data or when encryption fails.
Parameters¶
- data: ByteSeq
Returns¶
- None val ?
receive¶
Feed encrypted data from the transport into the session.
Returns what happened: SSLAccepted when data was accepted with nothing
else to report, SSLReady when the handshake completed, SSLAuthFail
when the peer's certificate was rejected, SSLError on failure, or
InvalidOperation when the session is no longer operational.
Parameters¶
- data: ByteSeq
Returns¶
send¶
Returns encrypted bytes to be passed to the destination, or None when
there is nothing to send.
Returns¶
dispose¶
Dispose of the session.
Returns¶
- None val