SSL_CTX_SET_TIMEOUT(3ossl)
π SSL_CTX_set_timeout, SSL_CTX_get_timeout β the session-cache timeout glow-up π
okay bestie, so this is from the OpenSSL 3ossl manual family, and it's literally just two lil functions that let you peek at and set how long sessions stay alive in the cache. no cap, that's the whole vibe.
β¨ NAME β¨
SSL_CTX_set_timeout, SSL_CTX_get_timeout β manipulate timeout values for session caching π
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
long SSL_CTX_set_timeout(SSL_CTX *ctx, long t);
long SSL_CTX_get_timeout(SSL_CTX *ctx);
π¦ DESCRIPTION π¦
So SSL_CTX_set_timeout() sets the timeout for newly created sessions on ctx to t. And listen β t has to be in seconds. like, seconds, bestie, don't get cute with it. β±οΈ
And SSL_CTX_get_timeout() just returns whatever timeout value ctx currently has set. that's it, that's the function. she's simple, she's iconic. π
π NOTES π
okay this is the part where you actually need to pay attention, so vibe check:
- Whenever a new session gets created, it's assigned a maximum lifetime. β¨
- This lifetime works by storing the creation time of the session plus the timeout value that was valid at that moment.
- If the actual current time is later than
creation time + timeout, then the session is not reused. expired, goodbye, blocked. π
And because of how this is implemented, there's a really important consequence:
All sessions behave according to the timeout value valid at the time of the session negotiation. Changes of the timeout value do not affect already established sessions. π₯
So if you change the timeout later, the sessions that already exist are like "not my problem, I was negotiated under the old rules." main character energy tbh.
If you wanna tweak the expiration time of a single session, you use the SSL_SESSION_get_time(3) family of functions. π«Ά
Expired sessions get removed from the internal session cache whenever SSL_CTX_flush_sessions(3) is called β either directly by the application, or automatically (see SSL_CTX_set_session_cache_mode(3)). π
The default value for the session timeout is decided on a per protocol basis, check SSL_get_default_timeout(3). And rn, all currently supported protocols have the same default timeout value of 300 seconds. β
This timeout value is also used as the ticket lifetime hint for stateless session tickets. and yep, it's also used as the timeout value within the ticket itself. π
Now, protocol-specific tea:
- For TLSv1.3, RFC8446 limits transmission of this value to 1 week (
604800seconds). so that's the ceiling, don't fight it. π - For TLSv1.2, tickets generated during an initial handshake use the value as specified. But tickets generated during a resumed handshake have a value of 0 for the ticket lifetime hint. π
π RETURN VALUES π
SSL_CTX_set_timeout()returns the previously set timeout value.SSL_CTX_get_timeout()returns the currently set timeout value.
π SEE ALSO π
ssl(7), SSL_CTX_set_session_cache_mode(3), SSL_SESSION_get_time(3), SSL_CTX_flush_sessions(3), SSL_get_default_timeout(3)
π COPYRIGHT π
Copyright 2001-2022 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>.
and that's the whole page bestie, tysm for reading, mwah πβ¨
this was OpenSSL 3.5.9, dated 2026-09-29, from the SSL_CTX_SET_TIMEOUT(3ossl) manual β slay, go forth and cache responsibly π¦π
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms