]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/SSL_CTX_sess_set_get_cb.pod
Following the license change, modify the boilerplates in doc/man3/
[thirdparty/openssl.git] / doc / man3 / SSL_CTX_sess_set_get_cb.pod
CommitLineData
8cbceba6
LJ
1=pod
2
3=head1 NAME
4
5SSL_CTX_sess_set_new_cb, SSL_CTX_sess_set_remove_cb, SSL_CTX_sess_set_get_cb, SSL_CTX_sess_get_new_cb, SSL_CTX_sess_get_remove_cb, SSL_CTX_sess_get_get_cb - provide callback functions for server side external session caching
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,
1bc74519 12 int (*new_session_cb)(SSL *, SSL_SESSION *));
8cbceba6 13 void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
e9b77246
BB
14 void (*remove_session_cb)(SSL_CTX *ctx,
15 SSL_SESSION *));
8cbceba6 16 void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
e9b77246
BB
17 SSL_SESSION (*get_session_cb)(SSL *,
18 const unsigned char *,
19 int, int *));
20
21 int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
22 SSL_SESSION *sess);
23 void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx,
24 SSL_SESSION *sess);
25 SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
26 const unsigned char *data,
27 int len, int *copy);
8cbceba6
LJ
28
29=head1 DESCRIPTION
30
31SSL_CTX_sess_set_new_cb() sets the callback function, which is automatically
32called whenever a new session was negotiated.
33
34SSL_CTX_sess_set_remove_cb() sets the callback function, which is
35automatically called whenever a session is removed by the SSL engine,
36because it is considered faulty or the session has become obsolete because
37of exceeding the timeout value.
38
39SSL_CTX_sess_set_get_cb() sets the callback function which is called,
40whenever a SSL/TLS client proposed to resume a session but the session
41could not be found in the internal session cache (see
9b86974e 42L<SSL_CTX_set_session_cache_mode(3)>).
8cbceba6
LJ
43(SSL/TLS server only.)
44
45SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb(), and
6e501c47
P
46SSL_CTX_sess_get_get_cb() retrieve the function pointers set by the
47corresponding set callback functions. If a callback function has not been
48set, the NULL pointer is returned.
8cbceba6
LJ
49
50=head1 NOTES
51
52In order to allow external session caching, synchronization with the internal
53session cache is realized via callback functions. Inside these callback
54functions, session can be saved to disk or put into a database using the
9b86974e 55L<d2i_SSL_SESSION(3)> interface.
8cbceba6
LJ
56
57The new_session_cb() is called, whenever a new session has been negotiated
58and session caching is enabled (see
9b86974e 59L<SSL_CTX_set_session_cache_mode(3)>).
8cbceba6 60The new_session_cb() is passed the B<ssl> connection and the ssl session
0bc6597d 61B<sess>. If the callback returns B<0>, the session will be immediately
5b3e5f00 62removed again. Note that in TLSv1.3, sessions are established after the main
6ff71494
MC
63handshake has completed. The server decides when to send the client the session
64information and this may occur some time after the end of the handshake (or not
65at all). This means that applications should expect the new_session_cb()
66function to be invoked during the handshake (for <= TLSv1.2) or after the
67handshake (for TLSv1.3). It is also possible in TLSv1.3 for multiple sessions to
68be established with a single connection. In these case the new_session_cb()
69function will be invoked multiple times.
70
71In TLSv1.3 it is recommended that each SSL_SESSION object is only used for
b8964668
MC
72resumption once. One way of enforcing that is for applications to call
73L<SSL_CTX_remove_session(3)> after a session has been used.
8cbceba6
LJ
74
75The remove_session_cb() is called, whenever the SSL engine removes a session
423b1a84
LJ
76from the internal cache. This happens when the session is removed because
77it is expired or when a connection was not shutdown cleanly. It also happens
78for all sessions in the internal session cache when
9b86974e 79L<SSL_CTX_free(3)> is called. The remove_session_cb() is passed
423b1a84 80the B<ctx> and the ssl session B<sess>. It does not provide any feedback.
8cbceba6
LJ
81
82The get_session_cb() is only called on SSL/TLS servers with the session id
83proposed by the client. The get_session_cb() is always called, also when
84session caching was disabled. The get_session_cb() is passed the
85B<ssl> connection, the session id of length B<length> at the memory location
86B<data>. With the parameter B<copy> the callback can require the
56fa8e69
LJ
87SSL engine to increment the reference count of the SSL_SESSION object,
88Normally the reference count is not incremented and therefore the
89session must not be explicitly freed with
9b86974e 90L<SSL_SESSION_free(3)>.
8cbceba6 91
1f13ad31
PY
92=head1 RETURN VALUES
93
94SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb() and SSL_CTX_sess_get_get_cb()
95return different callback function pointers respectively.
96
8cbceba6
LJ
97=head1 SEE ALSO
98
b97fdb57 99L<ssl(7)>, L<d2i_SSL_SESSION(3)>,
9b86974e
RS
100L<SSL_CTX_set_session_cache_mode(3)>,
101L<SSL_CTX_flush_sessions(3)>,
102L<SSL_SESSION_free(3)>,
103L<SSL_CTX_free(3)>
8cbceba6 104
e2f92610
RS
105=head1 COPYRIGHT
106
61f805c1 107Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
e2f92610 108
4746f25a 109Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
110this file except in compliance with the License. You can obtain a copy
111in the file LICENSE in the source distribution or at
112L<https://www.openssl.org/source/license.html>.
113
114=cut