Tls module

Tls_Error_Kind

enumSource

What went wrong, in one value for everything the module does: a bad certificate in a config, a handshake that failed, a peer that is not who it says it is, a connection that broke.

kind of a Tls_Error says which; .NONE is success. Branch on the kind, then show error_text(error) to a person (the line lives in temporary storage) or read detail(*error), error.io, error.alert and error.verify_flags for the specifics. Calls that return Io.Io_Error instead (read, write) leave the TLS reason in last_error(stream).

Example
config: Tls_Config;
config.certificate_chain_pem = "this is not a certificate";
config.private_key_pem = "this is not a key";

error := tls_config_init(*config);
assert(error.kind == .CONFIG);
assert(error_text(error).count > 0);

Doesn't run in the browser (skipped on wasm).

Members

NONE
no error: .{}
IO
the connection under TLS failed or timed out: io says how (.TIMED_OUT, .CANCELED, ...)
CONFIG
the config cannot be used: a certificate or key that does not parse, no system roots, ...
HANDSHAKE
the handshake failed: the peers share no protocol version, cipher or ALPN protocol, or one sent a fatal alert
VERIFY
the peer's certificate was not accepted (detail says why)
PROTOCOL
a record that does not decrypt or parse, or an alert from the peer, on an open connection
TRUNCATED
the connection ended without the peer's close_notify: the data may be incomplete
CLOSED
the stream was closed

See also