TLS_ACCEPT_SOCKET(3)
π
tls_accept_socket(3) β the libtls era begins
okay so bestie, this one is from the Library Functions Manual for libtls (and it links against libssl and libcrypto, iykyk) β and it's literally the "let the client in" page for a TLS server. π
The stars of the show are tls_accept_socket, tls_accept_fds, and tls_accept_cbs, and they all do one iconic thing: accept an incoming client connection in a TLS server. Periodt.
β¨ NAME β¨
tls_accept_socket, tls_accept_fds, tls_accept_cbs β accept an incoming client connection in a TLS server πΈ
β¨ SYNOPSIS β¨
library βlibtlsβ libssl libcrypto
#include <tls.h>
int
tls_accept_socket(struct tls *tls, struct tls **cctx, int socket);
int
tls_accept_fds(struct tls *tls, struct tls **cctx, int fd_read,
int fd_write);
int
tls_accept_cbs(struct tls *tls, struct tls **cctx,
ssize_t (*tls_read_cb)(struct tls *ctx, void *buf, size_t buflen, void *cb_arg),
ssize_t (*tls_write_cb)(struct tls *ctx, const void *buf, size_t buflen, void *cb_arg),
void *cb_arg);
like, look at that third one. it's giving callback main character energy. π
β¨ DESCRIPTION β¨
so first things first, bestie: you don't just roll up on tls_accept_socket() with nothing. π«Ά
You make a TLS server context tls with tls_server(3) and you configure it with tls_configure(3). Then, once you have an already established socket connection, the server accepts a new client connection by calling tls_accept_socket() on it. easy. slay.
Alternatively β yes there's an alternative, we love options β a new client connection can be accepted over a pair of existing file descriptors by calling tls_accept_fds(). two fds, one vibe. π¦
And then there's calling tls_accept_cbs(), which lets read and write callback functions handle data transfers. the specified cb_arg parameter gets passed back to the functions, and it can contain a pointer to any caller-specified data. so it's like, your little bag of stuff that travels with the callbacks. π
All these functions create a new context suitable for reading and writing and return it in *cctx. that's the whole point, that's the payoff, that *cctx is your new bestie. π
β¨ RETURN VALUES β¨
keep it simple, keep it cute:
0β success π-1β error π
that's it. that's the return value lore. no cap.
β¨ SEE ALSO β¨
go read these next, i'm obsessed with them for you:
β¨ HISTORY β¨
storytime, gather round π§
tls_accept_socket() appeared in OpenBSD 5.6 and got its final name in OpenBSD 5.7. glow-up era, fr.
tls_accept_fds() appeared in OpenBSD 5.8 and tls_accept_cbs() in OpenBSD 6.1. the family kept growing, we love to see it. π
β¨ AUTHORS β¨
- Joel Sing
<jsing@openbsd.org>π tls_accept_cbs()was written by Tobias Pape<tobias@netshed.de>β¨
bestie reminder: none of this works until your context is set up properly, and the callbacks version is only as good as the callbacks you hand it. π
okay that's the whole page!! π this came from the Debian build, dated July 7, 2025, and we're closing out on TLS_ACCEPT_SOCKET(3) β mwah, go accept some connections, you've got this πβ¨π«Ά
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
- Copyright (c) 2015 Joel Sing <jsing@openbsd.org>
- Copyright (c) 2016 Brent Cook <bcook@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms