1SSL_CTX_set_session_cache_mode(3) OpenSSL SSL_CTX_set_session_cache_mode(3)
2
3
4
6 SSL_CTX_set_session_cache_mode, SSL_CTX_get_session_cache_mode -
7 enable/disable session caching
8
10 #include <openssl/ssl.h>
11
12 long SSL_CTX_set_session_cache_mode(SSL_CTX ctx, long mode);
13 long SSL_CTX_get_session_cache_mode(SSL_CTX ctx);
14
16 SSL_CTX_set_session_cache_mode() enables/disables session caching by
17 setting the operational mode for ctx to <mode>.
18
19 SSL_CTX_get_session_cache_mode() returns the currently used cache mode.
20
22 The OpenSSL library can store/retrieve SSL/TLS sessions for later re‐
23 use. The sessions can be held in memory for each ctx, if more than one
24 SSL_CTX object is being maintained, the sessions are unique for each
25 SSL_CTX object.
26
27 In order to reuse a session, a client must send the session's id to the
28 server. It can only send exactly one id. The server then either agrees
29 to reuse the session or it starts a full handshake (to create a new
30 session).
31
32 A server will lookup up the session in its internal session storage. If
33 the session is not found in internal storage or lookups for the inter‐
34 nal storage have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP),
35 the server will try the external storage if available.
36
37 Since a client may try to reuse a session intended for use in a differ‐
38 ent context, the session id context must be set by the server (see
39 SSL_CTX_set_session_id_context(3)).
40
41 The following session cache modes and modifiers are available:
42
43 SSL_SESS_CACHE_OFF
44 No session caching for client or server takes place.
45
46 SSL_SESS_CACHE_CLIENT
47 Client sessions are added to the session cache. As there is no
48 reliable way for the OpenSSL library to know whether a session
49 should be reused or which session to choose (due to the abstract
50 BIO layer the SSL engine does not have details about the connec‐
51 tion), the application must select the session to be reused by
52 using the SSL_set_session(3) function. This option is not activated
53 by default.
54
55 SSL_SESS_CACHE_SERVER
56 Server sessions are added to the session cache. When a client pro‐
57 poses a session to be reused, the server looks for the correspond‐
58 ing session in (first) the internal session cache (unless
59 SSL_SESS_CACHE_NO_INTERNAL_LOOKUP is set), then (second) in the
60 external cache if available. If the session is found, the server
61 will try to reuse the session. This is the default.
62
63 SSL_SESS_CACHE_BOTH
64 Enable both SSL_SESS_CACHE_CLIENT and SSL_SESS_CACHE_SERVER at the
65 same time.
66
67 SSL_SESS_CACHE_NO_AUTO_CLEAR
68 Normally the session cache is checked for expired sessions every
69 255 connections using the SSL_CTX_flush_sessions(3) function. Since
70 this may lead to a delay which cannot be controlled, the automatic
71 flushing may be disabled and SSL_CTX_flush_sessions(3) can be
72 called explicitly by the application.
73
74 SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
75 By setting this flag, session-resume operations in an SSL/TLS
76 server will not automatically look up sessions in the internal
77 cache, even if sessions are automatically stored there. If external
78 session caching callbacks are in use, this flag guarantees that all
79 lookups are directed to the external cache. As automatic lookup
80 only applies for SSL/TLS servers, the flag has no effect on
81 clients.
82
83 SSL_SESS_CACHE_NO_INTERNAL_STORE
84 Depending on the presence of SSL_SESS_CACHE_CLIENT and/or
85 SSL_SESS_CACHE_SERVER, sessions negotiated in an SSL/TLS handshake
86 may be cached for possible reuse. Normally a new session is added
87 to the internal cache as well as any external session caching
88 (callback) that is configured for the SSL_CTX. This flag will pre‐
89 vent sessions being stored in the internal cache (though the appli‐
90 cation can add them manually using SSL_CTX_add_session(3)). Note:
91 in any SSL/TLS servers where external caching is configured, any
92 successful session lookups in the external cache (ie. for session-
93 resume requests) would normally be copied into the local cache
94 before processing continues - this flag prevents these additions to
95 the internal cache as well.
96
97 SSL_SESS_CACHE_NO_INTERNAL
98 Enable both SSL_SESS_CACHE_NO_INTERNAL_LOOKUP and
99 SSL_SESS_CACHE_NO_INTERNAL_STORE at the same time.
100
101 The default mode is SSL_SESS_CACHE_SERVER.
102
104 SSL_CTX_set_session_cache_mode() returns the previously set cache mode.
105
106 SSL_CTX_get_session_cache_mode() returns the currently set cache mode.
107
109 ssl(3), SSL_set_session(3), SSL_session_reused(3), SSL_CTX_add_ses‐
110 sion(3), SSL_CTX_sess_number(3), SSL_CTX_sess_set_cache_size(3),
111 SSL_CTX_sess_set_get_cb(3), SSL_CTX_set_session_id_context(3),
112 SSL_CTX_set_timeout(3), SSL_CTX_flush_sessions(3)
113
115 SSL_SESS_CACHE_NO_INTERNAL_STORE and SSL_SESS_CACHE_NO_INTERNAL were
116 introduced in OpenSSL 0.9.6h.
117
118
119
1200.9.8b 2002-10-29 SSL_CTX_set_session_cache_mode(3)