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