TLS_CONNECT(3)
β¨ TLS_CONNECT(3) β the tls_connect girlies π
ok so this is from the Library Functions Manual, and it's literally the whole tls_connect family. bestie, we're about to make your TLS client go get a connection. slay.
πΈ NAME πΈ
tls_connect, tls_connect_fds, tls_connect_servername, tls_connect_socket, tls_connect_cbs β telling a TLS client to go establish a connection, fr fr
π SYNOPSIS π
#include <tls.h>
int
tls_connect(struct tls *ctx, const char *host, const char *port);
int
tls_connect_fds(struct tls *ctx, int fd_read, int fd_write,
const char *servername);
int
tls_connect_servername(struct tls *ctx, const char *host,
const char *port, const char *servername);
int
tls_connect_socket(struct tls *ctx, int s, const char *servername);
int
tls_connect_cbs(struct tls *ctx,
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, const char *servername);
like. look at all those little functions. one of them is your moment, you just gotta pick. π
π¦ DESCRIPTION π¦
okay so picture this: you already made a TLS client context with tls_client(3) and you already configured it with tls_configure(3). iconic. now it's time to actually connect, and that's what tls_connect() is for.
Here's the whole vibe: tls_connect() will create a new socket, connect to the specified host and port, and then establish a secure connection. the port can be numeric or a service name β flexible queen. and if it's NULL? then a host of the format "hostname:port" is permitted. cute. the name to use for verification is inferred from the host value.
Then we have tls_connect_servername() β same behaviour, same energy, but the name to use for verification is explicitly provided. this is for the case where the TLS server name differs from the DNS name. iykyk, sometimes the vibe check name and the address name are just not the same person. π
Got an already existing socket and you want to glow it up? tls_connect_socket() upgrades it to a secure connection. instant main character energy. β¨
Alternatively β and this is lowkey the cool one β a secure connection can be established over a pair of existing file descriptors by calling tls_connect_fds().
And then there's tls_connect_cbs(), which lets read and write callback functions handle data transfers. the specified cb_arg parameter is passed back to the functions, and it can contain a pointer to any caller-specified data. so you can just... put your little stuff in there. obsessed. π«Ά
π RETURN VALUES π
these functions return 0 on success or -1 on error. that's it, that's the whole story. zero means we ate, negative one means we did not. π
π SEE ALSO π
tls_accept_socket(3)tls_client(3)tls_close(3)tls_config_ocsp_require_stapling(3)tls_configure(3)tls_handshake(3)tls_init(3)
go read the friends, they're all part of the same friend group. π
β HISTORY β
tls_connect() and tls_connect_socket() appeared in OpenBSD 5.6 and got their final names in OpenBSD 5.7. glow-up era. π
tls_connect_fds() and tls_connect_servername() appeared in OpenBSD 5.7, and tls_connect_cbs() in OpenBSD 6.1. the family kept growing, as it should. π¦
π AUTHORS π
- Joel Sing
<jsing@openbsd.org> - Reyk Floeter
<reyk@openbsd.org>
and tls_connect_cbs() was written by Tobias Pape <tobias@netshed.de> β special shoutout, we see you. π
no cap, this whole page came from the Debian build, dated July 9, 2018. love that for us. mwah, take care of your connections bestie ππΈ
π¦ where this page comes from
- alpine 3.22: libretls-doc 3.7.0-r2 Β· ISC AND ( BSD-3-Clause OR MIT )
- alpine 3.24: libretls-doc 3.8.1-r0 Β· ISC AND ( BSD-3-Clause OR MIT )
- arch rolling: libretls 3.8.1-3 Β· ISC AND BSD AND MIT
- debian bookworm: libtls-dev 3.7.0-4
- debian trixie: libtls-dev 3.8.1-2.1+b2
- epel 10: libretls-devel 3.8.1-4.el10_0 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- epel 9: libretls-devel 3.8.1-1.el9 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libretls-devel 3.8.1-6.fc43 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 43: libretls-devel 3.8.1-6.fc43 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libretls-devel 3.8.1-7.fc44 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- fedora 44: libretls-devel 3.8.1-7.fc44 Β· ISC AND BSD-3-Clause AND MIT AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: libretls 3.8.1
- nixpkgs unstable: libretls 3.8.1
- ubuntu jammy: libtls-dev 3.4.1-2build1
- ubuntu noble: libtls-dev 3.8.1-2.1build2
- ubuntu questing: libtls-dev 3.8.1-2.1build2
- ubuntu resolute: libtls-dev 3.8.1-2.1build3
- ubuntu stonking: libtls-dev 3.8.1-2.1build4
- Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
- Copyright (c) 2014, 2015 Joel Sing <jsing@openbsd.org>
- Copyright (c) 2016 Brent Cook <bcook@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms