SSL_CTX_SET_TIMEOUT(3SSL)

πŸ’– SSL_CTX_SET_TIMEOUT πŸ’–

okay bestie, welcome to the OpenSSL corner of the man pages, Volume 3SSL β€” today we're talking timeout values for session caching and honestly? it's giving control freak in the best way πŸŽ€


✨ 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);

yes bestie, that's literally it. two functions. tiny API, big consequences πŸ¦‹


πŸ‘‘ DESCRIPTION πŸ‘‘

SSL_CTX_set_timeout() sets the timeout for newly created sessions for ctx to t. and t has to be in seconds, no cap πŸ•°οΈ

SSL_CTX_get_timeout() returns the currently set timeout value for ctx. she just tells you what's up πŸ’œ


🌈 NOTES 🌈

okay so here's the lore, and it lowkey matters:

Whenever a new session is created, it gets assigned a maximum lifetime. That lifetime is stored by saving the creation time of the session plus the timeout value that was valid at that moment. So if the actual time is later than creation time plus timeout? the session is not reused. periodt πŸ’€

Because of how this is realized, all sessions behave according to the timeout value that was valid at the time of the session negotiation. Changes to the timeout value do not affect already established sessions. not me changing the timeout and expecting old sessions to care 😭 they do not, bestie, they're committed to their original vibe

If you wanna tweak the expiration time of one single session, use the SSL_SESSION_get_time(3) family of functions. one session at a time, main character energy ⭐

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)). so the cleanup is happening, she's just the one doing it 🧚

The default value for session timeout is decided on a per protocol basis β€” go look at SSL_get_default_timeout(3). and btw, all currently supported protocols share the same default timeout value of 300 seconds. slay, consistency πŸ’–

This timeout value does double duty: it's used as the ticket lifetime hint for stateless session tickets, and it's also used as the timeout value within the ticket itself. multi-talented fr fr πŸ‘‘

For TLSv1.3, RFC8446 limits transmission of this value to 1 week (604800 seconds). so like, no, you can't just set it to a gazillion and call it a day πŸ™ˆ

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. yeah. 0. it is what it is 😌


πŸ’… RETURN VALUES πŸ’…

SSL_CTX_set_timeout() returns the previously set timeout value. (past you's value, not the new one β€” read carefully bestie πŸŽ€)

SSL_CTX_get_timeout() returns the currently set timeout value.


πŸ¦‹ SEE ALSO πŸ¦‹


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! 🫢 this was OpenSSL 4.0.3, dated 2026-09-29, and it was the SSL_CTX_SET_TIMEOUT(3SSL) manual page β€” go set your timeouts, love you, bye ✨🌸

πŸ“¦ where this page comes from