TLS_CONN_VERSION(3)
π TLS_CONN_VERSION(3) π
okay bestie, welcome to the Library Functions Manual page for TLS_CONN_VERSION(3). this is the whole little family of functions you call when you wanna β¨inspect an established TLS connectionβ¨. no cap, it's a vibe check for your TLS handshake.
π NAME π
tls_conn_version, tls_conn_cipher, tls_conn_cipher_strength, tls_conn_alpn_selected, tls_conn_servername, tls_conn_session_resumed, tls_peer_cert_provided, tls_peer_cert_contains_name, tls_peer_cert_chain_pem, tls_peer_cert_issuer, tls_peer_cert_subject, tls_peer_cert_hash, tls_peer_cert_notbefore, tls_peer_cert_notafter β inspect an established TLS connection π
β¨ SYNOPSIS β¨
#include <tls.h>
const char *
tls_conn_version(struct tls *ctx);
const char *
tls_conn_cipher(struct tls *ctx);
int
tls_conn_cipher_strength(struct tls *ctx);
const char *
tls_conn_alpn_selected(struct tls *ctx);
const char *
tls_conn_servername(struct tls *ctx);
int
tls_conn_session_resumed(struct tls *ctx);
int
tls_peer_cert_provided(struct tls *ctx);
int
tls_peer_cert_contains_name(struct tls *ctx, const char *name);
const uint8_t *
tls_peer_cert_chain_pem(struct tls *ctx, size_t *size);
const char *
tls_peer_cert_issuer(struct tls *ctx);
const char *
tls_peer_cert_subject(struct tls *ctx);
const char *
tls_peer_cert_hash(struct tls *ctx);
time_t
tls_peer_cert_notbefore(struct tls *ctx);
time_t
tls_peer_cert_notafter(struct tls *ctx);
πΈ DESCRIPTION πΈ
so these functions hand you the tea β about a TLS connection. the one rule: they only succeed after the handshake is complete. before that? nothing, bestie, it's giving "come back later". π«Ά and heads up β this connection info applies to both clients and servers, unless the description says otherwise:
tls_conn_version()β returns a string that matches the TLS version negotiated with the peer connected toctx. π¦tls_conn_cipher()β returns a string that matches the cipher suite negotiated with the peer connected toctx.tls_conn_cipher_strength()β returns the strength in bits for the symmetric cipher being used with the peer connected toctx. lowkey iconic that you can just ask.tls_conn_alpn_selected()β returns a string naming the ALPN protocol selected for use with the peer connected toctx. if no protocol was selected, thenNULLis returned. πtls_conn_servername()β returns a string matching the servername that the client connected toctxrequested by sending a TLS Server Name Indication extension. (server only)tls_conn_session_resumed()β tells you whether a TLS session was resumed during the handshake with the server connected toctx. (client only)tls_peer_cert_provided()β checks if the peer ofctxhas provided a certificate. simple as that.tls_peer_cert_contains_name()β checks if the peer of a TLSctxhas provided a certificate that contains a SAN or CN matchingname. πtls_peer_cert_chain_pem()β returns a pointer to memory containing a PEM-encoded certificate chain for the peer certificate fromctx. β¨tls_peer_cert_subject()β returns a string matching the subject of the peer certificate fromctx.tls_peer_cert_issuer()β returns a string matching the issuer of the peer certificate fromctx.tls_peer_cert_hash()β returns a string matching a hash of the raw peer certificate fromctx, prefixed by a hash name followed by a colon. the hash currently used isSHA256, though ngl this could change in the future. if you wanna generate the hash string yourself for a certificate in filemycert.crt, you can use these commands:
h=$(openssl x509 -outform der -in mycert.crt | sha256)
printf "SHA256:${h}\n"
tls_peer_cert_notbefore()β returns the time matching the start of the validity period of the peer certificate fromctx. β°tls_peer_cert_notafter()β returns the time matching the end of the validity period of the peer certificate fromctx. don't let it expire bestie π
π«Ά RETURN VALUES π«Ά
tls_conn_session_resumed()returns1if a TLS session was resumed, or0if it was not.tls_peer_cert_provided()andtls_peer_cert_contains_name()return1if the check succeeds, or0if it does not.tls_peer_cert_notbefore()andtls_peer_cert_notafter()return a time in epoch-seconds on success, or-1on error.- the functions that return a pointer return
NULLon error or an out of memory condition. π
π₯ SEE ALSO π₯
tls_configure(3), tls_handshake(3), tls_init(3), tls_ocsp_process_response(3)
π HISTORY π
the way this all rolled out over time, periodt:
tls_conn_version(),tls_conn_cipher(),tls_peer_cert_provided(),tls_peer_cert_contains_name(),tls_peer_cert_issuer(),tls_peer_cert_subject(),tls_peer_cert_hash(),tls_peer_cert_notbefore(), andtls_peer_cert_notafter()appeared inOpenBSD 5.9. πtls_conn_servername()andtls_conn_alpn_selected()appeared inOpenBSD 6.1.tls_conn_session_resumed()appeared inOpenBSD 6.3.tls_conn_cipher_strength()appeared inOpenBSD 6.7. β
π AUTHORS π
- Bob Beck
<beck@openbsd.org> - Joel Sing
<jsing@openbsd.org>
absolute legends, fr fr π
okay that's the whole page bestie, go forth and inspect those connections π
β¨ this was the Debian build of TLS_CONN_VERSION(3), dated November 2, 2019. mwah, drink water, check your cert expiry dates ππ§
π¦ 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) 2015 Bob Beck <beck@openbsd.org>
- Copyright (c) 2016, 2018 Joel Sing <jsing@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms