1SSL_CTX_SESS_SET_GET_CB(3ossl)      OpenSSL     SSL_CTX_SESS_SET_GET_CB(3ossl)
2
3
4

NAME

6       SSL_CTX_sess_set_new_cb, SSL_CTX_sess_set_remove_cb,
7       SSL_CTX_sess_set_get_cb, SSL_CTX_sess_get_new_cb,
8       SSL_CTX_sess_get_remove_cb, SSL_CTX_sess_get_get_cb - provide callback
9       functions for server side external session caching
10

SYNOPSIS

12        #include <openssl/ssl.h>
13
14        void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,
15                                     int (*new_session_cb)(SSL *, SSL_SESSION *));
16        void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
17                                        void (*remove_session_cb)(SSL_CTX *ctx,
18                                                                  SSL_SESSION *));
19        void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
20                                     SSL_SESSION (*get_session_cb)(SSL *,
21                                                                   const unsigned char *,
22                                                                   int, int *));
23
24        int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
25                                                     SSL_SESSION *sess);
26        void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx,
27                                                         SSL_SESSION *sess);
28        SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl,
29                                                              const unsigned char *data,
30                                                              int len, int *copy);
31

DESCRIPTION

33       SSL_CTX_sess_set_new_cb() sets the callback function that is called
34       whenever a new session was negotiated.
35
36       SSL_CTX_sess_set_remove_cb() sets the callback function that is called
37       whenever a session is removed by the SSL engine.  For example, this can
38       occur because a session is considered faulty or has become obsolete
39       because of exceeding the timeout value.
40
41       SSL_CTX_sess_set_get_cb() sets the callback function that is called
42       whenever a TLS client proposed to resume a session but the session
43       could not be found in the internal session cache (see
44       SSL_CTX_set_session_cache_mode(3)).  (TLS server only.)
45
46       SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb(), and
47       SSL_CTX_sess_get_get_cb() retrieve the function pointers set by the
48       corresponding set callback functions. If a callback function has not
49       been set, the NULL pointer is returned.
50

NOTES

52       In order to allow external session caching, synchronization with the
53       internal session cache is realized via callback functions. Inside these
54       callback functions, session can be saved to disk or put into a database
55       using the d2i_SSL_SESSION(3) interface.
56
57       The new_session_cb() is called whenever a new session has been
58       negotiated and session caching is enabled (see
59       SSL_CTX_set_session_cache_mode(3)).  The new_session_cb() is passed the
60       ssl connection and the nascent ssl session sess.  Since sessions are
61       reference-counted objects, the reference count on the session is
62       incremented before the callback, on behalf of the application.  If the
63       callback returns 0, the session will be immediately removed from the
64       internal cache and the reference count released. If the callback
65       returns 1, the application retains the reference (for an entry in the
66       application-maintained "external session cache"), and is responsible
67       for calling SSL_SESSION_free() when the session reference is no longer
68       in use.
69
70       Note that in TLSv1.3, sessions are established after the main handshake
71       has completed. The server decides when to send the client the session
72       information and this may occur some time after the end of the handshake
73       (or not at all). This means that applications should expect the
74       new_session_cb() function to be invoked during the handshake (for <=
75       TLSv1.2) or after the handshake (for TLSv1.3). It is also possible in
76       TLSv1.3 for multiple sessions to be established with a single
77       connection. In these case the new_session_cb() function will be invoked
78       multiple times.
79
80       In TLSv1.3 it is recommended that each SSL_SESSION object is only used
81       for resumption once. One way of enforcing that is for applications to
82       call SSL_CTX_remove_session(3) after a session has been used.
83
84       The remove_session_cb() is called whenever the SSL engine removes a
85       session from the internal cache. This can happen when the session is
86       removed because it is expired or when a connection was not shutdown
87       cleanly. It also happens for all sessions in the internal session cache
88       when SSL_CTX_free(3) is called. The remove_session_cb() is passed the
89       ctx and the ssl session sess. It does not provide any feedback.
90
91       The get_session_cb() is only called on SSL/TLS servers, and is given
92       the session id proposed by the client. The get_session_cb() is always
93       called, even when session caching was disabled. The get_session_cb() is
94       passed the ssl connection and the session id of length length at the
95       memory location data. By setting the parameter copy to 1, the callback
96       can require the SSL engine to increment the reference count of the
97       SSL_SESSION object; setting copy to 0 causes the reference count to
98       remain unchanged.  If the get_session_cb() does not write to copy, the
99       reference count is incremented and the session must be explicitly freed
100       with SSL_SESSION_free(3).
101

RETURN VALUES

103       SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb() and
104       SSL_CTX_sess_get_get_cb() return different callback function pointers
105       respectively.
106

SEE ALSO

108       ssl(7), d2i_SSL_SESSION(3), SSL_CTX_set_session_cache_mode(3),
109       SSL_CTX_flush_sessions(3), SSL_SESSION_free(3), SSL_CTX_free(3)
110
112       Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
113
114       Licensed under the Apache License 2.0 (the "License").  You may not use
115       this file except in compliance with the License.  You can obtain a copy
116       in the file LICENSE in the source distribution or at
117       <https://www.openssl.org/source/license.html>.
118
119
120
1213.0.9                             2023-07-27    SSL_CTX_SESS_SET_GET_CB(3ossl)
Impressum