SSL_CTX_SET_...N_CACHE_MODE(3ossl)
π NAME π
okay so bestie, this page is all about SSL_CTX_set_session_cache_mode and SSL_CTX_get_session_cache_mode β literally the functions that enable/disable session caching. it's giving "let's remember this TLS session for later" energy, and it lives in the 3ossl manual. slay.
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
long SSL_CTX_set_session_cache_mode(SSL_CTX ctx, long mode);
long SSL_CTX_get_session_cache_mode(SSL_CTX ctx);
π DESCRIPTION π
SSL_CTX_set_session_cache_mode() enables/disables session caching by setting the operational mode for ctx to mode. periodt.
SSL_CTX_get_session_cache_mode() returns the currently used cache mode. it's the vibes check for your cache settings.
π¦ NOTES π¦
The OpenSSL library can store/retrieve SSL/TLS sessions for later reuse. The sessions can be held in memory for each ctx, and if more than one SSL_CTX object is being maintained, the sessions are unique for each SSL_CTX object. no cap.
In order to reuse a session, a client must send the session's id to the server. It can only send exactly one id. The server then either agrees to reuse the session or it starts a full handshake (to create a new session). literally one id, bestie, the server picks.
A server will look up the session in its internal session storage. If the session is not found in internal storage or lookups for the internal storage have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP), the server will try the external storage if available.
Since a client may try to reuse a session intended for use in a different context, the session id context must be set by the server (see SSL_CTX_set_session_id_context(3)). important π«Ά
The following session cache modes and modifiers are available:
SSL_SESS_CACHE_OFFβ No session caching for client or server takes place. just off, zero caching, bye.SSL_SESS_CACHE_CLIENTβ Client sessions are added to the session cache. As there is no reliable way for the OpenSSL library to know whether a session should be reused or which session to choose (due to the abstract BIO layer the SSL engine does not have details about the connection), the application must select the session to be reused by using theSSL_set_session(3)function. This option is not activated by default. so you gotta pick the session yourself, bestie.SSL_SESS_CACHE_SERVERβ Server sessions are added to the session cache. When a client proposes a session to be reused, the server looks for the corresponding session in (first) the internal session cache (unlessSSL_SESS_CACHE_NO_INTERNAL_LOOKUPis set), then (second) in the external cache if available. If the session is found, the server will try to reuse the session. This is the default. it's giving default main character energy.SSL_SESS_CACHE_BOTHβ Enable bothSSL_SESS_CACHE_CLIENTandSSL_SESS_CACHE_SERVERat the same time. both, because why not.SSL_SESS_CACHE_NO_AUTO_CLEARβ Normally the session cache is checked for expired sessions every 255 connections using theSSL_CTX_flush_sessions(3)function. Since this may lead to a delay which cannot be controlled, the automatic flushing may be disabled andSSL_CTX_flush_sessions(3)can be called explicitly by the application. so if that 255-connection delay is giving you anxiety, turn it off and flush manually.SSL_SESS_CACHE_NO_INTERNAL_LOOKUPβ By setting this flag, session-resume operations in an SSL/TLS server will not automatically look up sessions in the internal cache, even if sessions are automatically stored there. If external session caching callbacks are in use, this flag guarantees that all lookups are directed to the external cache. As automatic lookup only applies for SSL/TLS servers, the flag has no effect on clients. external cache only, no internal peeking πSSL_SESS_CACHE_NO_INTERNAL_STOREβ Depending on the presence ofSSL_SESS_CACHE_CLIENTand/orSSL_SESS_CACHE_SERVER, sessions negotiated in an SSL/TLS handshake may be cached for possible reuse. Normally a new session is added to the internal cache as well as any external session caching (callback) that is configured for theSSL_CTX. This flag will prevent sessions being stored in the internal cache (though the application can add them manually usingSSL_CTX_add_session(3)). Note: in any SSL/TLS servers where external caching is configured, any successful session lookups in the external cache (i.e. for session-resume requests) would normally be copied into the local cache before processing continues β this flag prevents these additions to the internal cache as well. no internal storage unless you manually add it, and no sneaky copies either.SSL_SESS_CACHE_NO_INTERNALβ Enable bothSSL_SESS_CACHE_NO_INTERNAL_LOOKUPandSSL_SESS_CACHE_NO_INTERNAL_STOREat the same time. combo deal.SSL_SESS_CACHE_UPDATE_TIMEβ Updates the timestamp of the session when it is used, increasing the lifespan of the session. The session timeout applies to last use, rather then creation time. so the session gets refreshed every time it's used, not just when it's born. obsessed.
The default mode is SSL_SESS_CACHE_SERVER. that's the one if you don't touch anything.
πΈ RETURN VALUES πΈ
SSL_CTX_set_session_cache_mode() returns the previously set cache mode.
SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
π₯ SEE ALSO π₯
ssl(7), SSL_set_session(3), SSL_session_reused(3), SSL_CTX_add_session(3), SSL_CTX_sess_number(3), SSL_CTX_sess_set_cache_size(3), SSL_CTX_sess_set_get_cb(3), SSL_CTX_set_session_id_context(3), SSL_CTX_set_timeout(3), SSL_CTX_flush_sessions(3)
π COPYRIGHT π
Copyright 2001-2021 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>.
okay that's the whole page bestie, ily, go cache some sessions responsibly π«Άβ¨
3.5.0 Β· 2026-09-25 Β· signed off with love from your fave Unix girly π π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms