
#use wml::openssl-macros area=docs page=SSL_get_session

<title>Documents, SSL_get_session(3)</title>

<h1>SSL_get_session(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SSL_get_session - retrieve TLS/SSL session data

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> SSL_SESSION *SSL_get_session(const SSL *ssl);
 SSL_SESSION *SSL_get0_session(const SSL *ssl);
 SSL_SESSION *SSL_get1_session(SSL *ssl);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_get_session()</CODE> returns a pointer to the <STRONG>SSL_SESSION</STRONG> actually used in
<STRONG>ssl</STRONG>. The reference count of the <STRONG>SSL_SESSION</STRONG> is not incremented, so that the pointer can become invalid by other
operations.

</P>
<P>
<CODE>SSL_get0_session()</CODE> is the same as
<CODE>SSL_get_session().</CODE>

</P>
<P>
<CODE>SSL_get1_session()</CODE> is the same as
<CODE>SSL_get_session(),</CODE> but the reference count of the <STRONG>SSL_SESSION</STRONG> is incremented by one.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The ssl session contains all information required to re-establish the
connection without a new handshake.

</P>
<P>
<CODE>SSL_get0_session()</CODE> returns a pointer to the actual session. As
the reference counter is not incremented, the pointer is only valid while
the connection is in use. If <A HREF="../ssl/SSL_clear.html#">SSL_clear(3)</A> or
<A HREF="../ssl/SSL_free.html#">SSL_free(3)</A> is called, the session may be removed completely (if considered bad), and
the pointer obtained will become invalid. Even if the session is valid, it
can be removed at any time due to timeout during <A HREF="../ssl/SSL_CTX_flush_sessions.html#">SSL_CTX_flush_sessions(3)</A>.

</P>
<P>
If the data is to be kept, <CODE>SSL_get1_session()</CODE> will increment
the reference count, so that the session will not be implicitly removed by
other operations but stays in memory. In order to remove the session
<A HREF="../ssl/SSL_SESSION_free.html#">SSL_SESSION_free(3)</A> must be explicitly called once to decrement the reference count again.

</P>
<P>
SSL_SESSION objects keep internal link information about the session cache
list, when being inserted into one SSL_CTX object's session cache. One
SSL_SESSION object, regardless of its reference count, must therefore only
be used with one SSL_CTX object (and the SSL objects created from this
SSL_CTX object).

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
The following return values can occur:

</P>
<DL>
<DT><STRONG><A NAME="item_NULL">NULL</A></STRONG><DD>
<P>
There is no session available in <STRONG>ssl</STRONG>.

</P>
<DT><STRONG><A NAME="item_Pointer">Pointer to an SSL</A></STRONG><DD>
<P>
The return value points to the data of an SSL session.

</P>
</DL>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../ssl/ssl.html#">ssl(3)</A>, <A HREF="../ssl/SSL_free.html#">SSL_free(3)</A>,
<A HREF="../ssl/SSL_clear.html#">SSL_clear(3)</A>,
<A HREF="../ssl/SSL_SESSION_free.html#">SSL_SESSION_free(3)</A>



</P>
:}


