1SSL_CTX_SESS_SET_GET_CB(3)          OpenSSL         SSL_CTX_SESS_SET_GET_CB(3)
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, which is
34       automatically called whenever a new session was negotiated.
35
36       SSL_CTX_sess_set_remove_cb() sets the callback function, which is
37       automatically called whenever a session is removed by the SSL engine,
38       because it is considered faulty or the session has become obsolete
39       because of exceeding the timeout value.
40
41       SSL_CTX_sess_set_get_cb() sets the callback function which is called,
42       whenever a SSL/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)).  (SSL/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 ssl session sess. If the callback returns 0, the
61       session will be immediately removed again. Note that in TLSv1.3,
62       sessions are established after the main handshake has completed. The
63       server decides when to send the client the session information and this
64       may occur some time after the end of the handshake (or not at all).
65       This means that applications should expect the new_session_cb()
66       function to be invoked during the handshake (for <= TLSv1.2) or after
67       the handshake (for TLSv1.3). It is also possible in TLSv1.3 for
68       multiple sessions to be established with a single connection. In these
69       case the new_session_cb() function will be invoked multiple times.
70
71       In TLSv1.3 it is recommended that each SSL_SESSION object is only used
72       for resumption once. One way of enforcing that is for applications to
73       call SSL_CTX_remove_session(3) after a session has been used.
74
75       The remove_session_cb() is called, whenever the SSL engine removes a
76       session from the internal cache. This happens when the session is
77       removed because it is expired or when a connection was not shutdown
78       cleanly. It also happens for all sessions in the internal session cache
79       when SSL_CTX_free(3) is called. The remove_session_cb() is passed the
80       ctx and the ssl session sess. It does not provide any feedback.
81
82       The get_session_cb() is only called on SSL/TLS servers with the session
83       id proposed by the client. The get_session_cb() is always called, also
84       when session caching was disabled. The get_session_cb() is passed the
85       ssl connection, the session id of length length at the memory location
86       data. With the parameter copy the callback can require the SSL engine
87       to increment the reference count of the SSL_SESSION object, Normally
88       the reference count is not incremented and therefore the session must
89       not be explicitly freed with SSL_SESSION_free(3).
90

RETURN VALUES

92       SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb() and
93       SSL_CTX_sess_get_get_cb() return different callback function pointers
94       respectively.
95

SEE ALSO

97       ssl(7), d2i_SSL_SESSION(3), SSL_CTX_set_session_cache_mode(3),
98       SSL_CTX_flush_sessions(3), SSL_SESSION_free(3), SSL_CTX_free(3)
99
101       Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
102
103       Licensed under the OpenSSL license (the "License").  You may not use
104       this file except in compliance with the License.  You can obtain a copy
105       in the file LICENSE in the source distribution or at
106       <https://www.openssl.org/source/license.html>.
107
108
109
1101.1.1d                            2019-10-03        SSL_CTX_SESS_SET_GET_CB(3)
Impressum