6.105. kink/tls/TLS

6.105.1. type tls

An either end of a TLS connection.

6.105.1.1. Tls.tcp

`tcp` returns a `tcp` val as the TCP connecting socket backing the TLS connection.

6.105.1.2. Tls.input(...[$config={}])

`input` returns an `input` of the TLS connection.

Config method:

• C.buffer(...[Max_buf_size])

If C.buffer is called, the result `input` will perform userspace buffering. If `Max_buf_size` is given, the buffer size does not exceed `Max_buf_size` in byte length. If C.buffer is not called, the result `input` will not perform userspace buffering.

When `close` is called for the result `input`, the TLS connection is closed. It's because there is no such feature to close only the input of a TLS connection.

Preconditions

The TLS connection must be open.

`Max_buf_size` must be a positive integer `num`.

6.105.1.3. Tls.output(...[$config={}])

`output` returns an `output` of the TLS connection.

Config method:

• C.buffer(...[Max_buf_size])

If C.buffer is called, the result `output` will perform userspace buffering. If `Max_buf_size` is given, the buffer size will not exceed `Max_buf_size` in byte length. If C.buffer is not called, the result `output` will not perform userspace buffering.

When `close` is called for the result `output`, the TLS connection is closed. It's because there is no such feature to close only the output of a TLS connection.

Preconditions

The TLS connection must be open.

`Max_buf_size` must be a positive integer `num`.

6.105.1.4. Tls.close(...[$config={}])

`close` closes the TLS connection.

Config methods:

• C.on_success($success): default = {}

• C.on_error($error): default = {(:Exc) Exc.raise }

If the TLS connection is successfully closed, `close` tail-calls $success with no argument.

If an IO error occurs, `close` tail-calls $error with an `exception`.

When the TLS connection is already closed, calling this method does nothing.

Note that the backing TCP connection is NOT closed by this method.

Preconditions

• $success must be a fun which takes no arg

• $error must be a fun which takes an `exception`

6.105.2. TLS.is?(Val)

`is?` returns whether `Val` is a val of `tls` type.