SSL_CTX_FLUSH_SESSIONS(3ossl)

πŸ’– SSL_CTX_FLUSH_SESSIONS πŸ’–

okay bestie, welcome to SSL_CTX_FLUSH_SESSIONS(3ossl) β€” the OpenSSL manual page for yeeting expired sessions out of your cache. this one is part of the OpenSSL 3.5.9 docs and it's lowkey so useful, let's get into it 🧹✨


✨ NAME ✨

SSL_CTX_flush_sessions_ex, SSL_CTX_flush_sessions β€” remove expired sessions πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/ssl.h>

void SSL_CTX_flush_sessions_ex(SSL_CTX *ctx, time_t tm);

and now the messy part πŸ™ˆ β€” the following functions have been deprecated since OpenSSL 3.4, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):

void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);

🌸 DESCRIPTION 🌸

SSL_CTX_flush_sessions_ex() causes a run through the session cache of ctx to remove sessions expired at time tm. it's giving janitor energy, it's giving spring cleaning, it's giving not my expired sessions, not my problem 🧼

SSL_CTX_flush_sessions() is an older variant of the function that is not Y2038 safe due to usage of long datatype instead of time_t. no cap, that's the whole reason it got deprecated πŸ’€


πŸ¦‹ NOTES πŸ¦‹

If enabled, the internal session cache will collect all sessions established up to the specified maximum number (see SSL_CTX_sess_set_cache_size()). As sessions will not be reused ones they are expired, they should be removed from the cache to save resources. This can either be done automatically whenever 255 new sessions were established (see SSL_CTX_set_session_cache_mode(3)) or manually by calling SSL_CTX_flush_sessions_ex(). so like β€” either the auto-cleanup hits at 255, or you do it yourself. your call, bestie 🫢

The parameter tm specifies the time which should be used for the expiration test, in most cases the actual time given by time(0) will be used.

SSL_CTX_flush_sessions_ex() will only check sessions stored in the internal cache. When a session is found and removed, the remove_session_cb is however called to synchronize with the external cache (see SSL_CTX_sess_set_get_cb(3)). so it's internal-cache-only, but it does ping the callback so your external cache stays in the loop β€” teamwork, periodt 🀝


⭐ RETURN VALUES ⭐

SSL_CTX_flush_sessions_ex() does not return a value. nothing, nada, it just does the thing and dips 😌


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ HISTORY πŸ‘‘

SSL_CTX_flush_sessions_ex() was added in OpenSSL 3.4. brand new era, main character debut πŸ’œ


Copyright 2001-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


that's the whole page bestie, go forth and flush responsibly πŸ’–

and that's a wrap!! this was version 3.5.9, dated 2026-09-29, and it's the SSL_CTX_FLUSH_SESSIONS(3ossl) page from the OpenSSL fam. slay, bye πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from