SSL_get_session.pod revision 337982
1=pod 2 3=head1 NAME 4 5SSL_get_session - retrieve TLS/SSL session data 6 7=head1 SYNOPSIS 8 9 #include <openssl/ssl.h> 10 11 SSL_SESSION *SSL_get_session(const SSL *ssl); 12 SSL_SESSION *SSL_get0_session(const SSL *ssl); 13 SSL_SESSION *SSL_get1_session(SSL *ssl); 14 15=head1 DESCRIPTION 16 17SSL_get_session() returns a pointer to the B<SSL_SESSION> actually used in 18B<ssl>. The reference count of the B<SSL_SESSION> is not incremented, so 19that the pointer can become invalid by other operations. 20 21SSL_get0_session() is the same as SSL_get_session(). 22 23SSL_get1_session() is the same as SSL_get_session(), but the reference 24count of the B<SSL_SESSION> is incremented by one. 25 26=head1 NOTES 27 28The ssl session contains all information required to re-establish the 29connection without a new handshake. 30 31A session will be automatically removed from the session cache and marked as 32non-resumable if the connection is not closed down cleanly, e.g. if a fatal 33error occurs on the connection or L<SSL_shutdown(3)> is not called prior to 34L<SSL_free(3)>. 35 36SSL_get0_session() returns a pointer to the actual session. As the 37reference counter is not incremented, the pointer is only valid while 38the connection is in use. If L<SSL_clear(3)|SSL_clear(3)> or 39L<SSL_free(3)|SSL_free(3)> is called, the session may be removed completely 40(if considered bad), and the pointer obtained will become invalid. Even 41if the session is valid, it can be removed at any time due to timeout 42during L<SSL_CTX_flush_sessions(3)|SSL_CTX_flush_sessions(3)>. 43 44If the data is to be kept, SSL_get1_session() will increment the reference 45count, so that the session will not be implicitly removed by other operations 46but stays in memory. In order to remove the session 47L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> must be explicitly called once 48to decrement the reference count again. 49 50SSL_SESSION objects keep internal link information about the session cache 51list, when being inserted into one SSL_CTX object's session cache. 52One SSL_SESSION object, regardless of its reference count, must therefore 53only be used with one SSL_CTX object (and the SSL objects created 54from this SSL_CTX object). 55 56=head1 RETURN VALUES 57 58The following return values can occur: 59 60=over 4 61 62=item NULL 63 64There is no session available in B<ssl>. 65 66=item Pointer to an SSL 67 68The return value points to the data of an SSL session. 69 70=back 71 72=head1 SEE ALSO 73 74L<ssl(3)|ssl(3)>, L<SSL_free(3)|SSL_free(3)>, 75L<SSL_clear(3)|SSL_clear(3)>, 76L<SSL_SESSION_free(3)|SSL_SESSION_free(3)> 77 78=cut 79