Correct wrong usage information.
[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 if the session is removed because
64 it is expired or when a connection was not shutdown cleanly. The
65 remove_session_cb() is passed the B<ctx> and the ssl session B<sess>.
66 It does not provide any feedback.
67
68 The get_session_cb() is only called on SSL/TLS servers with the session id
69 proposed by the client. The get_session_cb() is always called, also when
70 session caching was disabled. The get_session_cb() is passed the
71 B<ssl> connection, the session id of length B<length> at the memory location
72 B<data>. With the parameter B<copy> the callback can require the
73 SSL engine to increment the reference count of the SSL_SESSION object,
74 Normally the reference count is not incremented and therefore the
75 session must not be explicitly freed with
76 L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>.
77
78 =head1 SEE ALSO
79
80 L<ssl(3)|ssl(3)>, L<d2i_SSL_SESSION(3)|d2i_SSL_SESSION(3)>,
81 L<SSL_CTX_set_session_cache_mode(3)|SSL_CTX_set_session_cache_mode(3)>,
82 L<SSL_CTX_flush_sessions(3)|<SSL_CTX_flush_sessions(3)>,
83 L<SSL_SESSION_free(3)|SSL_SESSION_free(3)>
84
85 =cut