DTLS¶
A DTLS session manages handshakes, encryption and decryption. It is not tied to any transport layer.
DTLS is the datagram variant of TLS. It provides the same authentication and
encryption guarantees over unreliable transports like UDP. This type is
separate from SSL because DTLS and TLS sessions are not interchangeable:
a TLS context cannot create a DTLS session and vice versa.
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 shutdown.
After calling this, drain send to deliver the encrypted close_notify
bytes to the transport.
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