xtc_tls(3)

---

xtc_tls(3)

TLS over async sockets

XTC_TLS(3) Library Functions Manual XTC_TLS(3)

xtc_tls_ctx_create, xtc_tls_ctx_destroy, xtc_tls_create, xtc_tls_destroy, xtc_tls_handshake, xtc_tls_read, xtc_tls_write, xtc_tls_shutdown, xtc_tls_wants_read, xtc_tls_wants_writeTLS over async sockets

#include <xtc.h>
#include <xtc_tls.h>

xtc_tls provides TLS 1.2 / 1.3 over xtc_io sockets. The implementation selects a backend at configure time (‘--with-tls=openssl|none|auto’); in v0.x only OpenSSL is implemented.

:

xtc_tls_ctx_t
Per-process state: cert, key, CA bundle, version range, ALPN profile. Created once via () with role (XTC_TLS_SERVER or XTC_TLS_CLIENT) plus opts.
xtc_tls_t
Per-connection state. Wraps a single fd. Created via (ctx, fd, &out).

:

xtc_tls_create(ctx, fd, &tls);
for (;;) {
    int rc = xtc_tls_handshake(tls);
    if (rc == XTC_OK) break;
    if (rc != XTC_E_AGAIN) abort();
    uint32_t want = xtc_tls_wants_read(tls)
                  ? XTC_IO_READABLE : XTC_IO_WRITABLE;
    xtc_proc_wait_fd(fd, want, -1, &revents);
}

() and () follow the same pattern: return XTC_OK on progress, XTC_E_AGAIN when the fd needs more poll iterations.

() performs the bidirectional close-notify dance; same WANT_* translation.

xtc_tls_opts_t fields:

cert_file, key_file
PEM paths for server-side certificate.
ca_file
PEM CA bundle for verifying the peer.
verify_peer
to require + validate the peer's cert.
alpn_protos
ALPN wire-form list.
min_version, max_version
or XTC_TLS_VER_13.

xtc_io(3), xtc_net(3), xtc_proc(3), xtc(7)

Appeared in xtc 0.1. See docs/M_TLS.md for backend pluggability planning.

May 28, 2026 Debian

View the mdoc source