SSL_CTX_SET_TIMEOUT(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… SSL_CTX_SET_TIMEOUT β€” session caching timeout vibes

okay bestie, so this is one of those pages from the Library Functions Manual (libssl / libcrypto territory, we love her), and it's genuinely such an easy read. Let's get into it ✨


🌸 NAME

SSL_CTX_set_timeout, SSL_CTX_get_timeout β€” the two functions that literally just manipulate timeout values for session caching πŸŽ€


✨ SYNOPSIS

so you're gonna need the libssl library, plus libcrypto, and you pull in the header like this:

#include <openssl/ssl.h>

and then the two icons themselves:

long
SSL_CTX_set_timeout(SSL_CTX *ctx, long t);

long
SSL_CTX_get_timeout(SSL_CTX *ctx);

that's it. that's the whole gate. 🫢


πŸ¦‹ DESCRIPTION

SSL_CTX_set_timeout() sets the timeout for newly created sessions for ctx to t. and like β€” important detail, bestie β€” the timeout value t must be given in seconds. no minutes, no vibes-based units, seconds. ⏰

SSL_CTX_get_timeout() returns the currently set timeout value for ctx. it's the getter. she gets. πŸ’…

now here's where it gets kinda cute conceptually: whenever a new session is created, it is assigned a maximum lifetime. this lifetime is specified by storing the creation time of the session and the timeout value valid at this time. so if the actual time is later than creation time plus timeout, the session is simply not reused. expired. ghosted. πŸ’€

and because that's how it's realized, all sessions behave according to the timeout value that was valid at the time of the session negotiation. meaning: changes of the timeout value do not affect already established sessions. no cap. once a session is out there living its life, retconning the timeout doesn't touch it. πŸ™ˆ

if you do want to mess with a single session's expiration time, you can β€” via the SSL_SESSION_get_time(3) family of functions. very targeted, very main character energy. πŸ‘‘

so when do expired sessions actually get the boot? they're removed from the internal session cache whenever SSL_CTX_flush_sessions(3) is called β€” either directly by the application, or automatically (peep SSL_CTX_set_session_cache_mode(3) for that). πŸ”₯

and about the default: the default value for session timeout is decided on a per-protocol basis β€” see SSL_get_default_timeout(3). and here's the fun fact: all currently supported protocols have the same default timeout value of 300 seconds. iconic, honestly. 🌈


πŸŽ€ RETURN VALUES

  • SSL_CTX_set_timeout() β†’ returns the previously set timeout value. yes, she gives you the old one back. nostalgic. πŸ₯Ί
  • SSL_CTX_get_timeout() β†’ returns the currently set timeout value. straightforward. slay. ⭐

πŸ‘‘ SEE ALSO

ssl(3), SSL_CTX_flush_sessions(3), SSL_CTX_set_session_cache_mode(3), SSL_get_default_timeout(3), SSL_SESSION_get_time(3)

go read those too, iykyk πŸ’–


🧚 HISTORY

SSL_CTX_set_timeout() and SSL_CTX_get_timeout() first appeared in SSLeay 0.6.1, and have been available since OpenBSD 2.4. ancient. legendary. still relevant. periodt. 🌸


ok that's the whole page bestie, go set some timeouts responsibly πŸ’œ

mwah πŸ’‹ this cutie came from the Debian build, dated June 8, 2025 β€” that's the source and version and date, all folded up in a little bow for you πŸŽ€ see you in the next manpage, love u, bye!

πŸ“¦ where this page comes from