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

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

<h1>SSL_CTX_add_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_CTX_add_session, SSL_add_session, SSL_CTX_remove_session,
SSL_remove_session - manipulate session cache

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c);
 int SSL_add_session(SSL_CTX *ctx, SSL_SESSION *c);
</PRE>
<PRE> int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c);
 int SSL_remove_session(SSL_CTX *ctx, SSL_SESSION *c);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_CTX_add_session()</CODE> adds the session <STRONG>c</STRONG> to the context <STRONG>ctx</STRONG>. The reference count for session <STRONG>c</STRONG> is incremented by 1. If a session with the same session id already exists,
the old session is removed by calling
<A HREF="../ssl/SSL_SESSION_free.html#">SSL_SESSION_free(3)</A>.

</P>
<P>
<CODE>SSL_CTX_remove_session()</CODE> removes the session <STRONG>c</STRONG> from the context <STRONG>ctx</STRONG>.
<A HREF="../ssl/SSL_SESSION_free.html#">SSL_SESSION_free(3)</A> is called once for <STRONG>c</STRONG>.

</P>
<P>
<CODE>SSL_add_session()</CODE> and <CODE>SSL_remove_session()</CODE> are
synonyms for their SSL_CTX_*() counterparts.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
When adding a new session to the internal session cache, it is examined
whether a session with the same session id already exists. In this case it
is assumed that both sessions are identical. If the same session is stored
in a different SSL_SESSION object, The old session is removed and replaced
by the new session. If the session is actually identical (the SSL_SESSION
object is identical), <CODE>SSL_CTX_add_session()</CODE> is a no-op, and
the return value is 0.

</P>
<P>
If a server SSL_CTX is configured with the SSL_SESS_CACHE_NO_INTERNAL_STORE
flag then the internal cache will not be populated automatically by new
sessions negotiated by the SSL/TLS implementation, even though the internal
cache will be searched automatically for session-resume requests (the
latter can be surpressed by SSL_SESS_CACHE_NO_INTERNAL_LOOKUP). So the
application can use <CODE>SSL_CTX_add_session()</CODE> directly to have
full control over the sessions that can be resumed if desired.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
The following values are returned by all functions:

</P>
<DL>
<DT><STRONG><A NAME="item_0">0</A></STRONG><DD>
<PRE> The operation failed. In case of the add operation, it was tried to add
 the same (identical) session twice. In case of the remove operation, the
 session was not found in the cache.
</PRE>
<DT><STRONG><A NAME="item_1">1
 
 The operation succeeded.</A></STRONG><DD>
</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_CTX_set_session_cache_mode.html#">SSL_CTX_set_session_cache_mode(3)</A>,
<A HREF="../ssl/SSL_SESSION_free.html#">SSL_SESSION_free(3)</A>



</P>
:}

