SSL_CTX_FLUSH_SESSIONS(3ossl)
π 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:
- automatically, whenever 255 new sessions were established (see
SSL_CTX_set_session_cache_mode(3)), or - manually, by calling
SSL_CTX_flush_sessions_ex()
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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms