1 .\" $OpenBSD: SSL_CTX_sess_set_get_cb.3,v 1.2 2016/11/30 16:25:29 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
5 .\" Copyright (c) 2001, 2002, 2003, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: November 30 2016 $
53 .Dt SSL_CTX_SESS_SET_GET_CB 3
56 .Nm SSL_CTX_sess_set_new_cb ,
57 .Nm SSL_CTX_sess_set_remove_cb ,
58 .Nm SSL_CTX_sess_set_get_cb ,
59 .Nm SSL_CTX_sess_get_new_cb ,
60 .Nm SSL_CTX_sess_get_remove_cb ,
61 .Nm SSL_CTX_sess_get_get_cb
62 .Nd provide callback functions for server side external session caching
66 .Fo SSL_CTX_sess_set_new_cb
68 .Fa "int (*new_session_cb)(SSL *, SSL_SESSION *)"
71 .Fo SSL_CTX_sess_set_remove_cb
73 .Fa "void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *)"
76 .Fo SSL_CTX_sess_set_get_cb
78 .Fa "SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *)"
81 .Fo "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))"
82 .Fa "struct ssl_st *ssl"
83 .Fa "SSL_SESSION *sess"
86 .Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))"
87 .Fa "struct ssl_ctx_st *ctx"
88 .Fa "SSL_SESSION *sess"
91 .Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))"
92 .Fa "struct ssl_st *ssl"
93 .Fa "unsigned char *data"
98 .Fo "(*new_session_cb)"
99 .Fa "struct ssl_st *ssl"
100 .Fa "SSL_SESSION *sess"
103 .Fo "(*remove_session_cb)"
104 .Fa "struct ssl_ctx_st *ctx"
105 .Fa "SSL_SESSION *sess"
108 .Fo "(*get_session_cb)"
109 .Fa "struct ssl_st *ssl"
110 .Fa "unsigned char *data"
115 .Fn SSL_CTX_sess_set_new_cb
116 sets the callback function which is automatically called whenever a new session
119 .Fn SSL_CTX_sess_set_remove_cb
120 sets the callback function which is automatically called whenever a session is
121 removed by the SSL engine (because it is considered faulty or the session has
122 become obsolete because of exceeding the timeout value).
124 .Fn SSL_CTX_sess_set_get_cb
125 sets the callback function which is called whenever a SSL/TLS client proposes
126 to resume a session but the session cannot be found in the internal session
128 .Xr SSL_CTX_set_session_cache_mode 3 ) .
129 (SSL/TLS server only.)
131 .Fn SSL_CTX_sess_get_new_cb ,
132 .Fn SSL_CTX_sess_get_remove_cb ,
134 .Fn SSL_CTX_sess_get_get_cb
135 retrieve the function pointers of the provided callback functions.
136 If a callback function has not been set, the
140 In order to allow external session caching, synchronization with the internal
141 session cache is realized via callback functions.
142 Inside these callback functions, session can be saved to disk or put into a
144 .Xr d2i_SSL_SESSION 3
149 function is called whenever a new session has been negotiated and session
150 caching is enabled (see
151 .Xr SSL_CTX_set_session_cache_mode 3 ) .
156 connection and the ssl session
158 If the callback returns 0, the session will be immediately removed again.
161 .Fn remove_session_cb
162 is called whenever the SSL engine removes a session from the internal cache.
163 This happens when the session is removed because it is expired or when a
164 connection was not shut down cleanly.
165 It also happens for all sessions in the internal session cache when
169 .Fn remove_session_cb
170 function is passed the
176 It does not provide any feedback.
180 function is only called on SSL/TLS servers with the session id proposed by the
184 function is always called, also when session caching was disabled.
189 connection, the session id of length
191 at the memory location
195 the callback can require the SSL engine to increment the reference count of the
198 Normally the reference count is not incremented and therefore the session must
199 not be explicitly freed with
200 .Xr SSL_SESSION_free 3 .
202 .Xr d2i_SSL_SESSION 3 ,
204 .Xr SSL_CTX_flush_sessions 3 ,
206 .Xr SSL_CTX_set_session_cache_mode 3 ,
207 .Xr SSL_SESSION_free 3