Skip to content

DTLS

[Source]

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.

class ref DTLS

Public Functions

alpn_selected

[Source]

The protocol identifier negotiated via ALPN, or None when no protocol has been selected.

fun box alpn_selected()
: (ALPNProtocolName | None val)

Returns


close

[Source]

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.

fun ref close()
: None val

Returns


read

[Source]

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.

fun ref read(
  expect: USize val = 0)
: SSLReadResult

Parameters

Returns


write

[Source]

Encrypt application data for sending. Raises an error when the session is not ready for application data or when encryption fails.

fun ref write(
  data: ByteSeq)
: None val ?

Parameters

Returns


receive

[Source]

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.

fun ref receive(
  data: ByteSeq)
: SSLReceiveResult

Parameters

Returns


send

[Source]

Returns encrypted bytes to be passed to the destination, or None when there is nothing to send.

fun ref send()
: (Array[U8 val] iso^ | None val)

Returns


dispose

[Source]

Dispose of the session.

fun ref dispose()
: None val

Returns