SSL_SESSION_GET_TIME(3ossl)
π SSL_SESSION_GET_TIME(3ossl) β like, the whole session time + timeout situation
okay so bestie, this is a page from the OpenSSL manual (you already knew that from the 3ossl up there, mwah) and it's all about the two lil numbers that decide how long a session gets to live: its creation time and its timeout. grab a strawberry π and let's go.
β¨ NAME β¨
SSL_SESSION_get_time, SSL_SESSION_set_time, SSL_SESSION_get_timeout, SSL_SESSION_set_timeout, SSL_SESSION_get_time_ex, SSL_SESSION_set_time_ex, SSL_get_time, SSL_set_time, SSL_get_timeout, SSL_set_timeout β retrieve and manipulate session time and timeout settings. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
long SSL_SESSION_get_timeout(const SSL_SESSION *s);
long SSL_SESSION_set_timeout(SSL_SESSION *s, long tm);
long SSL_get_timeout(const SSL_SESSION *s);
long SSL_set_timeout(SSL_SESSION *s, long tm);
time_t SSL_SESSION_get_time_ex(const SSL_SESSION *s);
time_t SSL_SESSION_set_time_ex(SSL_SESSION *s, time_t tm);
okay and now the part where i need you to sit down, bestie π«Ά β the following functions have been deprecated since OpenSSL 3.4, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
long SSL_SESSION_get_time(const SSL_SESSION *s);
long SSL_SESSION_set_time(SSL_SESSION *s, long tm);
long SSL_get_time(const SSL_SESSION *s);
long SSL_set_time(SSL_SESSION *s, long tm);
yeah. them. we'll get to why. it's giving 2038 energy π
π DESCRIPTION π
SSL_SESSION_get_time_ex() returns the time at which the session s was established. the time is given in seconds since the Epoch and is therefore compatible to the time delivered by the time() call. iconic, standard, no notes β¨
SSL_SESSION_set_time_ex() replaces the creation time of the session s with the chosen value tm. you're literally rewriting history, but make it consenting π
SSL_SESSION_get_timeout() returns the timeout value set for session s, in seconds. that's the session's personal little countdown π°οΈ
SSL_SESSION_set_timeout() sets the timeout value for session s, in seconds, to tm.
SSL_SESSION_get_time() and SSL_SESSION_set_time() β okay so these use the long datatype instead of time_t, and that is exactly why they're deprecated: they are not Y2038-safe on 32 bit systems. no cap. and heads up: such systems still need to be configured to use 64 bit time_t to be able to avoid overflow in system time. so yeah, deprecated does not mean "problem solved bestie", it means "go fix your config" π€
SSL_get_time(), SSL_set_time(), SSL_get_timeout(), and SSL_set_timeout() are straight-up synonyms for their SSL_SESSION_*() counterparts. same function, shorter name, main character energy π
π¦ NOTES π¦
sessions are expired by examining the creation time and the timeout value. both get set at the creation time of the session β to the actual time, and to the default timeout value at creation, respectively, as set by SSL_CTX_set_timeout(3).
and here's the fun part: using these functions, it is possible to extend or shorten the lifetime of the session. you have the power. use it responsibly π§
β RETURN VALUES β
SSL_SESSION_get_time_ex()andSSL_SESSION_get_timeout()return the currently valid values.SSL_SESSION_set_time_ex()returns time on success.SSL_SESSION_set_timeout()returns1on success.- If any of the functions is passed the
NULLpointer for the sessions,0is returned. π
π BUGS π
the data type long is typically 32 bits on many systems, hence the old functions SSL_SESSION_get_time() and SSL_SESSION_set_time() are not always Y2038 safe. that's the bug. that's literally the bug. 32 bits is not enough bits, and no amount of manifesting will change that π
π SEE ALSO π
ssl(7), SSL_CTX_set_timeout(3), SSL_get_default_timeout(3)
π HISTORY π
the functions SSL_SESSION_get_time_ex() and SSL_SESSION_set_time_ex() were added in OpenSSL 3.3. late to the party but they ate π
π 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>.
okay that's the whole page, bestie, you're officially caught up π«Ά this absolute icon of a manual came from OpenSSL 3.5.0, dated 2026-09-25, and it's filed under SSL_SESSION_GET_TIME(3ossl) β go set a timeout on something and slay π
β¨
π¦ 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