| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "SSL_CTX_SET_SESSION_CACHE_MODE 3SSL" |
| 58 |
.TH SSL_CTX_SET_SESSION_CACHE_MODE 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
SSL_CTX_set_session_cache_mode, SSL_CTX_get_session_cache_mode \- enable/disable session caching |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 1 |
| 68 |
\& #include <openssl/ssl.h> |
| 69 |
\& |
| 70 |
\& long SSL_CTX_set_session_cache_mode(SSL_CTX ctx, long mode); |
| 71 |
\& long SSL_CTX_get_session_cache_mode(SSL_CTX ctx); |
| 72 |
.Ve |
| 73 |
.SH DESCRIPTION |
| 74 |
.IX Header "DESCRIPTION" |
| 75 |
\&\fBSSL_CTX_set_session_cache_mode()\fR enables/disables session caching |
| 76 |
by setting the operational mode for \fBctx\fR to <mode>. |
| 77 |
.PP |
| 78 |
\&\fBSSL_CTX_get_session_cache_mode()\fR returns the currently used cache mode. |
| 79 |
.SH NOTES |
| 80 |
.IX Header "NOTES" |
| 81 |
The OpenSSL library can store/retrieve SSL/TLS sessions for later reuse. |
| 82 |
The sessions can be held in memory for each \fBctx\fR, if more than one |
| 83 |
SSL_CTX object is being maintained, the sessions are unique for each SSL_CTX |
| 84 |
object. |
| 85 |
.PP |
| 86 |
In order to reuse a session, a client must send the session's id to the |
| 87 |
server. It can only send exactly one id. The server then either |
| 88 |
agrees to reuse the session or it starts a full handshake (to create a new |
| 89 |
session). |
| 90 |
.PP |
| 91 |
A server will look up the session in its internal session storage. If the |
| 92 |
session is not found in internal storage or lookups for the internal storage |
| 93 |
have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP), the server will try |
| 94 |
the external storage if available. |
| 95 |
.PP |
| 96 |
Since a client may try to reuse a session intended for use in a different |
| 97 |
context, the session id context must be set by the server (see |
| 98 |
\&\fBSSL_CTX_set_session_id_context\fR\|(3)). |
| 99 |
.PP |
| 100 |
The following session cache modes and modifiers are available: |
| 101 |
.IP SSL_SESS_CACHE_OFF 4 |
| 102 |
.IX Item "SSL_SESS_CACHE_OFF" |
| 103 |
No session caching for client or server takes place. |
| 104 |
.IP SSL_SESS_CACHE_CLIENT 4 |
| 105 |
.IX Item "SSL_SESS_CACHE_CLIENT" |
| 106 |
Client sessions are added to the session cache. As there is no reliable way |
| 107 |
for the OpenSSL library to know whether a session should be reused or which |
| 108 |
session to choose (due to the abstract BIO layer the SSL engine does not |
| 109 |
have details about the connection), the application must select the session |
| 110 |
to be reused by using the \fBSSL_set_session\fR\|(3) |
| 111 |
function. This option is not activated by default. |
| 112 |
.IP SSL_SESS_CACHE_SERVER 4 |
| 113 |
.IX Item "SSL_SESS_CACHE_SERVER" |
| 114 |
Server sessions are added to the session cache. When a client proposes a |
| 115 |
session to be reused, the server looks for the corresponding session in (first) |
| 116 |
the internal session cache (unless SSL_SESS_CACHE_NO_INTERNAL_LOOKUP is set), |
| 117 |
then (second) in the external cache if available. If the session is found, the |
| 118 |
server will try to reuse the session. This is the default. |
| 119 |
.IP SSL_SESS_CACHE_BOTH 4 |
| 120 |
.IX Item "SSL_SESS_CACHE_BOTH" |
| 121 |
Enable both SSL_SESS_CACHE_CLIENT and SSL_SESS_CACHE_SERVER at the same time. |
| 122 |
.IP SSL_SESS_CACHE_NO_AUTO_CLEAR 4 |
| 123 |
.IX Item "SSL_SESS_CACHE_NO_AUTO_CLEAR" |
| 124 |
Normally the session cache is checked for expired sessions every |
| 125 |
255 connections using the |
| 126 |
\&\fBSSL_CTX_flush_sessions\fR\|(3) function. Since |
| 127 |
this may lead to a delay which cannot be controlled, the automatic |
| 128 |
flushing may be disabled and |
| 129 |
\&\fBSSL_CTX_flush_sessions\fR\|(3) can be called |
| 130 |
explicitly by the application. |
| 131 |
.IP SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 4 |
| 132 |
.IX Item "SSL_SESS_CACHE_NO_INTERNAL_LOOKUP" |
| 133 |
By setting this flag, session-resume operations in an SSL/TLS server will not |
| 134 |
automatically look up sessions in the internal cache, even if sessions are |
| 135 |
automatically stored there. If external session caching callbacks are in use, |
| 136 |
this flag guarantees that all lookups are directed to the external cache. |
| 137 |
As automatic lookup only applies for SSL/TLS servers, the flag has no effect on |
| 138 |
clients. |
| 139 |
.IP SSL_SESS_CACHE_NO_INTERNAL_STORE 4 |
| 140 |
.IX Item "SSL_SESS_CACHE_NO_INTERNAL_STORE" |
| 141 |
Depending on the presence of SSL_SESS_CACHE_CLIENT and/or SSL_SESS_CACHE_SERVER, |
| 142 |
sessions negotiated in an SSL/TLS handshake may be cached for possible reuse. |
| 143 |
Normally a new session is added to the internal cache as well as any external |
| 144 |
session caching (callback) that is configured for the SSL_CTX. This flag will |
| 145 |
prevent sessions being stored in the internal cache (though the application can |
| 146 |
add them manually using \fBSSL_CTX_add_session\fR\|(3)). Note: |
| 147 |
in any SSL/TLS servers where external caching is configured, any successful |
| 148 |
session lookups in the external cache (i.e. for session-resume requests) would |
| 149 |
normally be copied into the local cache before processing continues \- this flag |
| 150 |
prevents these additions to the internal cache as well. |
| 151 |
.IP SSL_SESS_CACHE_NO_INTERNAL 4 |
| 152 |
.IX Item "SSL_SESS_CACHE_NO_INTERNAL" |
| 153 |
Enable both SSL_SESS_CACHE_NO_INTERNAL_LOOKUP and |
| 154 |
SSL_SESS_CACHE_NO_INTERNAL_STORE at the same time. |
| 155 |
.IP SSL_SESS_CACHE_UPDATE_TIME 4 |
| 156 |
.IX Item "SSL_SESS_CACHE_UPDATE_TIME" |
| 157 |
Updates the timestamp of the session when it is used, increasing the lifespan |
| 158 |
of the session. The session timeout applies to last use, rather then creation |
| 159 |
time. |
| 160 |
.PP |
| 161 |
The default mode is SSL_SESS_CACHE_SERVER. |
| 162 |
.SH "RETURN VALUES" |
| 163 |
.IX Header "RETURN VALUES" |
| 164 |
\&\fBSSL_CTX_set_session_cache_mode()\fR returns the previously set cache mode. |
| 165 |
.PP |
| 166 |
\&\fBSSL_CTX_get_session_cache_mode()\fR returns the currently set cache mode. |
| 167 |
.SH "SEE ALSO" |
| 168 |
.IX Header "SEE ALSO" |
| 169 |
\&\fBssl\fR\|(7), \fBSSL_set_session\fR\|(3), |
| 170 |
\&\fBSSL_session_reused\fR\|(3), |
| 171 |
\&\fBSSL_CTX_add_session\fR\|(3), |
| 172 |
\&\fBSSL_CTX_sess_number\fR\|(3), |
| 173 |
\&\fBSSL_CTX_sess_set_cache_size\fR\|(3), |
| 174 |
\&\fBSSL_CTX_sess_set_get_cb\fR\|(3), |
| 175 |
\&\fBSSL_CTX_set_session_id_context\fR\|(3), |
| 176 |
\&\fBSSL_CTX_set_timeout\fR\|(3), |
| 177 |
\&\fBSSL_CTX_flush_sessions\fR\|(3) |
| 178 |
.SH COPYRIGHT |
| 179 |
.IX Header "COPYRIGHT" |
| 180 |
Copyright 2001\-2021 The OpenSSL Project Authors. All Rights Reserved. |
| 181 |
.PP |
| 182 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 183 |
this file except in compliance with the License. You can obtain a copy |
| 184 |
in the file LICENSE in the source distribution or at |
| 185 |
<https://www.openssl.org/source/license.html>. |