SSL_CTX_FLUSH_SESSIONS(3ossl)

πŸ“¦ version 15.1, in freebsd 15.1

πŸ’… SSL_CTX_FLUSH_SESSIONS(3ossl)

okay so bestie, welcome to the 3ossl girlies' corner of the OpenSSL manual πŸ’– this one is short and sweet β€” it's all about yeeting expired sessions out of your cache so they stop taking up space like that one friend who never leaves the group chat. let's get into it ✨


πŸŽ€ NAME πŸŽ€

SSL_CTX_flush_sessions_ex, SSL_CTX_flush_sessions β€” remove expired sessions. that's it, that's the whole vibe. literally just "bye expired sessions, don't let the door hit you" πŸ¦‹


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

void SSL_CTX_flush_sessions_ex(SSL_CTX *ctx, time_t tm);

so the next one is deprecated as of OpenSSL 3.4, and you can hide it entirely by defining OPENSSL_API_COMPAT with a suitable version value β€” see openssl_user_macros(7) for the deets πŸ‘‘

void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);

ngl the difference is literally just long vs time_t and that one tiny change is the whole Y2038 drama, more on that below πŸ™ˆ


🌸 DESCRIPTION 🌸

SSL_CTX_flush_sessions_ex() does a whole run through the session cache of ctx and removes sessions that are expired at time tm. like a closet cleanout but for your session cache, slay 🧹✨

SSL_CTX_flush_sessions() is the older variant of the function and β€” this is the important part, no cap β€” it is not Y2038 safe, because it uses the long datatype instead of time_t. so it's giving ✨legacy✨ and that's why it's deprecated πŸ’€


πŸ¦‹ NOTES πŸ¦‹

if enabled, the internal session cache will collect all sessions established up to the specified maximum number (check SSL_CTX_sess_set_cache_size() for that one, iykyk).

and here's the thing β€” sessions will not be reused once they are expired, so you should remove them from the cache to save resources. think of it as not keeping expired milk in the fridge, bestie πŸ₯›πŸ˜­ this can either happen:

the parameter tm specifies the time which should be used for the expiration test β€” and in most cases the actual time given by time(0) will be used ⏰

highkey important: SSL_CTX_flush_sessions_ex() will only check sessions stored in the internal cache. when a session is found and removed, though, the remove_session_cb is called to synchronize with the external cache (see SSL_CTX_sess_set_get_cb(3)). so the external cache stays in the loop, periodt 🫢


πŸ’œ RETURN VALUES πŸ’œ

SSL_CTX_flush_sessions_ex() does not return a value. it's a void function, she gives nothing and she takes nothing, main character energy πŸ‘‘πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

go read those, they're iconic, I promise 🌈⭐


🌟 HISTORY 🌟

SSL_CTX_flush_sessions_ex() was added in OpenSSL 3.4. the new girl on the block, we stan πŸ’–


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>.

fr fr read the license before you ship, bestie, it's giving "respect the paperwork" πŸ“„βœ¨

and that's the whole page!! πŸŽ€ this lil manpage is from OpenSSL 3.5.6, dated 2026-04-07 β€” so when you cite it, cite it cute πŸ«ΆπŸ’œ go forth and flush those sessions, you absolute icon 🌸

πŸ“¦ where this page comes from