Skip to content

SSL

[Source]

An SSL session manages handshakes, encryption and decryption. It is not tied to any transport layer.

class ref SSL

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 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.

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