SSL_CTX_FLUSH_SESSIONS(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… SSL_CTX_FLUSH_SESSIONS(3) πŸ’…

okay so this is a page from the Library Functions Manual (the libssl / libcrypto girlies, you know the ones) and it's literally about cleaning out expired sessions. it's giving spring cleaning but for your TLS cache. 🧹✨


🌸 NAME 🌸

SSL_CTX_flush_sessions β€” remove expired sessions, bestie. that's it, that's the whole vibe. πŸ—‘οΈ


✨ SYNOPSIS ✨

kay so first you gotta pull in the header, the library is libssl libcrypto and the include is this:

#include <openssl/ssl.h>

and then the function itself, no cap:

void
SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);

πŸ¦‹ DESCRIPTION πŸ¦‹

so SSL_CTX_flush_sessions() does a whole little walk-through of the session cache of ctx and removes every session that's expired at time tm. like a bouncer checking IDs but for expirations. πŸ‘‘βœ¨

if it's enabled, the internal session cache will collect all the sessions established up to the specified maximum number (peep SSL_CTX_sess_set_cache_size(3) for that one). and here's the thing β€” once sessions are expired they are not getting reused, so lowkey they should just be removed from the cache to save resources. iconic resource management. πŸ’–

and you've got two ways to do it:

the parameter tm specifies the time that should be used for the expiration test β€” and in most cases the actual time given by time(0) will be used. fr fr, that's the usual move. ⏰

heads up: SSL_CTX_flush_sessions() will only check sessions stored in the internal cache. when a session is found and removed, though, the remove_session_cb does get called to synchronize with the external cache (see SSL_CTX_sess_set_get_cb(3)). so the external cache still gets its little notification, periodt. 🫢

🌈 SEE ALSO 🌈

go read these next, iykwim:


πŸŽ€ HISTORY πŸŽ€

SSL_CTX_flush_sessions() first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4. she's been around a minute, and honestly? she ate. πŸ’…β­


and that's the whole page bestie 🫢 this drop was brought to you by Debian, dated June 8, 2025, filed under SSL_CTX_FLUSH_SESSIONS(3) β€” go flush those sessions, mwah πŸ’–πŸ§šβœ¨

πŸ“¦ where this page comes from