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

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

<h1>SSL_CTX_set_session_id_context(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="#WARNINGS">WARNINGS</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_set_session_id_context, SSL_set_session_id_context - set context
within which session can be reused (server side only)

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx,
                                    unsigned int sid_ctx_len);
 int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx,
                                unsigned int sid_ctx_len);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_CTX_set_session_id_context()</CODE> sets the context <STRONG>sid_ctx</STRONG> of length
<STRONG>sid_ctx_len</STRONG> within which a session can be reused for the <STRONG>ctx</STRONG> object.

</P>
<P>
<CODE>SSL_set_session_id_context()</CODE> sets the context <STRONG>sid_ctx</STRONG> of length
<STRONG>sid_ctx_len</STRONG> within which a session can be reused for the <STRONG>ssl</STRONG> object.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Sessions are generated within a certain context. When exporting/importing
sessions with <STRONG>i2d_SSL_SESSION</STRONG>/<STRONG>d2i_SSL_SESSION</STRONG> it would be possible, to re-import a session generated from another context
(e.g. another application), which might lead to malfunctions. Therefore
each application must set its own session id context <STRONG>sid_ctx</STRONG> which is used to distinguish the contexts and is stored in exported
sessions. The <STRONG>sid_ctx</STRONG> can be any kind of binary data with a given length, it is therefore
possible to use e.g. the name of the application and/or the hostname and/or
service name ...

</P>
<P>
The session id context becomes part of the session. The session id context
is set by the SSL/TLS server. The
<CODE>SSL_CTX_set_session_id_context()</CODE> and
<CODE>SSL_set_session_id_context()</CODE> functions are therefore only
useful on the server side.

</P>
<P>
OpenSSL clients will check the session id context returned by the server
when reusing a session.

</P>
<P>
The maximum length of the <STRONG>sid_ctx</STRONG> is limited to
<STRONG>SSL_MAX_SSL_SESSION_ID_LENGTH</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="WARNINGS">WARNINGS</A></H1>
<P>
If the session id context is not set on an SSL/TLS server and client
certificates are used, stored sessions will not be reused but a fatal error
will be flagged and the handshake will fail.

</P>
<P>
If a server returns a different session id context to an OpenSSL client
when reusing a session, an error will be flagged and the handshake will
fail. OpenSSL servers will always return the correct session id context, as
an OpenSSL server checks the session id context itself before reusing a
session as described above.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>SSL_CTX_set_session_id_context()</CODE> and
<CODE>SSL_set_session_id_context()</CODE> return the following values:

</P>
<DL>
<DT><STRONG><A NAME="item_0">0</A></STRONG><DD>
<P>
The length <STRONG>sid_ctx_len</STRONG> of the session id context <STRONG>sid_ctx</STRONG> exceeded the maximum allowed length of <STRONG>SSL_MAX_SSL_SESSION_ID_LENGTH</STRONG>. The error is logged to the error stack.

</P>
<DT><STRONG><A NAME="item_1">1</A></STRONG><DD>
<P>
The operation succeeded.

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



</P>
:}

