POD: Fix list termination
[openssl.git] / doc / ssl / SSL_CTX_sess_set_get_cb.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_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,
12                               int (*new_session_cb)(SSL *, SSL_SESSION *));
13  void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx,
14            void (*remove_session_cb)(SSL_CTX *ctx, SSL_SESSION *));
15  void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx,
16            SSL_SESSION (*get_session_cb)(SSL *, unsigned char *, int, int *));
17
18  int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx))(struct ssl_st *ssl, SSL_SESSION *sess);
19  void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx))(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
20  SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx))(struct ssl_st *ssl, unsigned char *data, int len, int *copy);
21
22  int (*new_session_cb)(struct ssl_st *ssl, SSL_SESSION *sess);
23  void (*remove_session_cb)(struct ssl_ctx_st *ctx, SSL_SESSION *sess);
24  SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, unsigned char *data,
25                int len, int *copy);
26
27 =head1 DESCRIPTION
28
29 SSL_CTX_sess_set_new_cb() sets the callback function, which is automatically
30 called whenever a new session was negotiated.
31
32 SSL_CTX_sess_set_remove_cb() sets the callback function, which is
33 automatically called whenever a session is removed by the SSL engine,
34 because it is considered faulty or the session has become obsolete because
35 of exceeding the timeout value.
36
37 SSL_CTX_sess_set_get_cb() sets the callback function which is called,
38 whenever a SSL/TLS client proposed to resume a session but the session
39 could not be found in the internal session cache (see
40 L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>).
41 (SSL/TLS server only.)
42
43 SSL_CTX_sess_get_new_cb(), SSL_CTX_sess_get_remove_cb(), and
44 SSL_CTX_sess_get_get_cb() allow to retrieve the function pointers of the
45 provided callback functions. If a callback function has not been set,
46 the NULL pointer is returned.
47
48 =head1 NOTES
49
50 In order to allow external session caching, synchronization with the internal
51 session cache is realized via callback functions. Inside these callback
52 functions, session can be saved to disk or put into a database using the
53 L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)> interface.
54
55 The new_session_cb() is called, whenever a new session has been negotiated
56 and session caching is enabled (see
57 L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>).
58 The new_session_cb() is passed the B<ssl> connection and the ssl session
59 B<sess>. If the callback returns B<0>, the session will be immediately
60 removed again.
61
62 The remove_session_cb() is called, whenever the SSL engine removes a session
63 from the internal cache. This happens when the session is removed because
64 it is expired or when a connection was not shutdown cleanly. It also happens
65 for all sessions in the internal session cache when
66 L<SSL_CTX_free(3)|SSL_CTX_free(3)> is called. The remove_session_cb() is passed
67 the B<ctx> and the ssl session B<sess>. It does not provide any feedback.
68
69 The get_session_cb() is only called on SSL/TLS servers with the session id
70 proposed by the client. The get_session_cb() is always called, also when
71 session caching was disabled. The get_session_cb() is passed the
72 B<ssl> connection, the session id of length B<length> at the memory location
73 B<data>. With the parameter B<copy> the callback can require the
74 SSL engine to increment the reference count of the SSL_SESSION object,
75 Normally the reference count is not incremented and therefore the
76 session must not be explicitly freed with
77 L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
78
79 =head1 SEE ALSO
80
81 L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
82 L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
83 L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>,
84 L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>,
85 L<SSL_CTX_free(3)|SSL_CTX_free(3)>
86
87 =cut