=head1 NAME
-SSL_CTX_flush_sessions - remove expired sessions
+SSL_CTX_flush_sessions_ex, SSL_CTX_flush_sessions - remove expired sessions
=head1 SYNOPSIS
#include <openssl/ssl.h>
+ void SSL_CTX_flush_sessions_ex(SSL_CTX *ctx, time_t tm);
+
+The following functions have been deprecated since OpenSSL 3.4, and can be
+hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
+see L<openssl_user_macros(7)>:
+
void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
=head1 DESCRIPTION
-SSL_CTX_flush_sessions() causes a run through the session cache of
+SSL_CTX_flush_sessions_ex() causes a run through the session cache of
B<ctx> to remove sessions expired at time B<tm>.
+SSL_CTX_flush_sessions() is an older variant of the function that is not
+Y2038 safe due to usage of long datatype instead of time_t.
+
=head1 NOTES
If enabled, the internal session cache will collect all sessions established
removed from the cache to save resources. This can either be done
automatically whenever 255 new sessions were established (see
L<SSL_CTX_set_session_cache_mode(3)>)
-or manually by calling SSL_CTX_flush_sessions().
+or manually by calling SSL_CTX_flush_sessions_ex().
The parameter B<tm> specifies the time which should be used for the
expiration test, in most cases the actual time given by time(0)
will be used.
-SSL_CTX_flush_sessions() will only check sessions stored in the internal
+SSL_CTX_flush_sessions_ex() will only check sessions stored in the internal
cache. When a session is found and removed, the remove_session_cb is however
called to synchronize with the external cache (see
L<SSL_CTX_sess_set_get_cb(3)>).
=head1 RETURN VALUES
-SSL_CTX_flush_sessions() does not return a value.
+SSL_CTX_flush_sessions_ex() does not return a value.
=head1 SEE ALSO
__owur int SSL_want(const SSL *s);
__owur int SSL_clear(SSL *s);
+#ifndef OPENSSL_NO_DEPRECATED_3_4
+OSSL_DEPRECATEDIN_3_4_FOR("not Y2038-safe, replace with SSL_CTX_flush_sessions_ex()")
void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm);
+#endif
+void SSL_CTX_flush_sessions_ex(SSL_CTX *ctx, time_t tm);
__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s);
__owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s);
* (See ticket [openssl.org #212].)
*/
if (a->sessions != NULL)
- SSL_CTX_flush_sessions(a, 0);
+ SSL_CTX_flush_sessions_ex(a, 0);
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);
lh_SSL_SESSION_free(a->sessions);
else
stat = &s->session_ctx->stats.sess_accept_good;
if ((ssl_tsan_load(s->session_ctx, stat) & 0xff) == 0xff)
- SSL_CTX_flush_sessions(s->session_ctx, (unsigned long)time(NULL));
+ SSL_CTX_flush_sessions_ex(s->session_ctx, time(NULL));
}
}
return 0;
}
+#ifndef OPENSSL_NO_DEPRECATED_3_4
void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
+{
+ SSL_CTX_flush_sessions_ex(s, (time_t) t);
+}
+#endif
+
+void SSL_CTX_flush_sessions_ex(SSL_CTX *s, time_t t)
{
STACK_OF(SSL_SESSION) *sk;
SSL_SESSION *current;
goto end;
/* This should remove "early" */
- SSL_CTX_flush_sessions(ctx, now + TIMEOUT - 1);
+ SSL_CTX_flush_sessions_ex(ctx, now + TIMEOUT - 1);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* This should remove "middle" */
- SSL_CTX_flush_sessions(ctx, now + TIMEOUT + 1);
+ SSL_CTX_flush_sessions_ex(ctx, now + TIMEOUT + 1);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr(late->prev))
goto end;
/* This should remove "late" */
- SSL_CTX_flush_sessions(ctx, now + TIMEOUT + 11);
+ SSL_CTX_flush_sessions_ex(ctx, now + TIMEOUT + 11);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr_null(late->prev))
goto end;
/* This should remove all of them */
- SSL_CTX_flush_sessions(ctx, 0);
+ SSL_CTX_flush_sessions_ex(ctx, 0);
if (!TEST_ptr_null(early->prev)
|| !TEST_ptr_null(middle->prev)
|| !TEST_ptr_null(late->prev))
SSL_add_client_CA 187 3_0_0 EXIST::FUNCTION:
SSL_CTX_get0_security_ex_data 188 3_0_0 EXIST::FUNCTION:
SSL_get_ex_data 189 3_0_0 EXIST::FUNCTION:
-SSL_CTX_flush_sessions 190 3_0_0 EXIST::FUNCTION:
+SSL_CTX_flush_sessions 190 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_4
SSL_use_PrivateKey 191 3_0_0 EXIST::FUNCTION:
DTLSv1_client_method 192 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_1_1_0,DTLS1_METHOD
SSL_CTX_dane_mtype_set 193 3_0_0 EXIST::FUNCTION:
SSL_poll 584 3_3_0 EXIST::FUNCTION:
SSL_SESSION_get_time_ex 585 3_3_0 EXIST::FUNCTION:
SSL_SESSION_set_time_ex 586 3_3_0 EXIST::FUNCTION:
+SSL_CTX_flush_sessions_ex 587 3_4_0 EXIST::FUNCTION: