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