import libssl (LibreSSL 2.5.4)
[unleashed.git] / lib / libssl / man / SSL_CTX_sess_set_get_cb.3
blob5448c97ed8c8cdbe0ef5794ca42895d0b867edc3
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
3 .\"
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.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\"
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\"
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
18 .\"    distribution.
19 .\"
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/)"
24 .\"
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.
29 .\"
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.
33 .\"
34 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\"    acknowledgment:
36 .\"    "This product includes software developed by the OpenSSL Project
37 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\"
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.
51 .\"
52 .Dd $Mdocdate: November 30 2016 $
53 .Dt SSL_CTX_SESS_SET_GET_CB 3
54 .Os
55 .Sh NAME
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
63 .Sh SYNOPSIS
64 .In openssl/ssl.h
65 .Ft void
66 .Fo SSL_CTX_sess_set_new_cb
67 .Fa "SSL_CTX *ctx"
68 .Fa "int (*new_session_cb)(SSL *, SSL_SESSION *)"
69 .Fc
70 .Ft void
71 .Fo SSL_CTX_sess_set_remove_cb
72 .Fa "SSL_CTX *ctx"
73 .Fa "void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *)"
74 .Fc
75 .Ft void
76 .Fo SSL_CTX_sess_set_get_cb
77 .Fa "SSL_CTX *ctx"
78 .Fa "SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *)"
79 .Fc
80 .Ft int
81 .Fo "(*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))"
82 .Fa "struct ssl_st *ssl"
83 .Fa "SSL_SESSION *sess"
84 .Fc
85 .Ft void
86 .Fo "(*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))"
87 .Fa "struct ssl_ctx_st *ctx"
88 .Fa "SSL_SESSION *sess"
89 .Fc
90 .Ft SSL_SESSION *
91 .Fo "(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))"
92 .Fa "struct ssl_st *ssl"
93 .Fa "unsigned char *data"
94 .Fa "int len"
95 .Fa "int *copy"
96 .Fc
97 .Ft int
98 .Fo "(*new_session_cb)"
99 .Fa "struct ssl_st *ssl"
100 .Fa "SSL_SESSION *sess"
102 .Ft void
103 .Fo "(*remove_session_cb)"
104 .Fa "struct ssl_ctx_st *ctx"
105 .Fa "SSL_SESSION *sess"
107 .Ft SSL_SESSION *
108 .Fo "(*get_session_cb)"
109 .Fa "struct ssl_st *ssl"
110 .Fa "unsigned char *data"
111 .Fa "int len"
112 .Fa "int *copy"
114 .Sh DESCRIPTION
115 .Fn SSL_CTX_sess_set_new_cb
116 sets the callback function which is automatically called whenever a new session
117 was negotiated.
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
127 cache (see
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
137 .Dv NULL
138 pointer is returned.
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
143 database using the
144 .Xr d2i_SSL_SESSION 3
145 interface.
148 .Fn new_session_cb
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 ) .
153 .Fn new_session_cb
154 is passed the
155 .Fa ssl
156 connection and the ssl session
157 .Fa sess .
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
166 .Xr SSL_CTX_free 3
167 is called.
169 .Fn remove_session_cb
170 function is passed the
171 .Fa ctx
172 and the
173 .Vt ssl
174 session
175 .Fa sess .
176 It does not provide any feedback.
179 .Fn get_session_cb
180 function is only called on SSL/TLS servers with the session id proposed by the
181 client.
183 .Fn get_session_cb
184 function is always called, also when session caching was disabled.
186 .Fn get_session_cb
187 is passed the
188 .Fa ssl
189 connection, the session id of length
190 .Fa length
191 at the memory location
192 .Fa data .
193 With the parameter
194 .Fa copy
195 the callback can require the SSL engine to increment the reference count of the
196 .Vt SSL_SESSION
197 object,
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 .
201 .Sh SEE ALSO
202 .Xr d2i_SSL_SESSION 3 ,
203 .Xr ssl 3 ,
204 .Xr SSL_CTX_flush_sessions 3 ,
205 .Xr SSL_CTX_free 3 ,
206 .Xr SSL_CTX_set_session_cache_mode 3 ,
207 .Xr SSL_SESSION_free 3