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

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

<h1>SSL_CTX_new(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_new - create a new SSL_CTX object as framework for TLS/SSL enabled
functions

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_CTX_new()</CODE> creates a new <STRONG>SSL_CTX</STRONG> object as framework to establish TLS/SSL enabled connections.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The SSL_CTX object uses <STRONG>method</STRONG> as connection method. The methods exist in a generic type (for client and
server use), a server only type, and a client only type. <STRONG>method</STRONG> can be of the following types:

</P>
<DL>
<DT><STRONG><A NAME="item_SSLv2_method">SSLv2_method(void), SSLv2_server_method(void), SSLv2_client_method(void)</A></STRONG><DD>
<P>
A TLS/SSL connection established with these methods will only understand
the SSLv2 protocol. A client will send out SSLv2 client hello messages and
will also indicate that it only understand SSLv2. A server will only
understand SSLv2 client hello messages.

</P>
<DT><STRONG><A NAME="item_SSLv3_method">SSLv3_method(void), SSLv3_server_method(void), SSLv3_client_method(void)</A></STRONG><DD>
<P>
A TLS/SSL connection established with these methods will only understand
the SSLv3 protocol. A client will send out SSLv3 client hello messages and
will indicate that it only understands SSLv3. A server will only understand
SSLv3 client hello messages. This especially means, that it will not
understand SSLv2 client hello messages which are widely used for
compatibility reasons, see SSLv23_*_method().

</P>
<DT><STRONG><A NAME="item_TLSv1_method">TLSv1_method(void), TLSv1_server_method(void), TLSv1_client_method(void)</A></STRONG><DD>
<P>
A TLS/SSL connection established with these methods will only understand
the TLSv1 protocol. A client will send out TLSv1 client hello messages and
will indicate that it only understands TLSv1. A server will only understand
TLSv1 client hello messages. This especially means, that it will not
understand SSLv2 client hello messages which are widely used for
compatibility reasons, see SSLv23_*_method(). It will also not understand
SSLv3 client hello messages.

</P>
<DT><STRONG><A NAME="item_SSLv23_method">SSLv23_method(void), SSLv23_server_method(void), SSLv23_client_method(void)</A></STRONG><DD>
<P>
A TLS/SSL connection established with these methods will understand the
SSLv2, SSLv3, and TLSv1 protocol. A client will send out SSLv2 client hello
messages and will indicate that it also understands SSLv3 and TLSv1. A
server will understand SSLv2, SSLv3, and TLSv1 client hello messages. This
is the best choice when compatibility is a concern.

</P>
</DL>
<P>
The list of protocols available can later be limited using the
SSL_OP_NO_SSLv2, SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1 options of the <STRONG>SSL_CTX_set_options()</STRONG> or
<STRONG>SSL_set_options()</STRONG> functions. Using these options it is possible to choose e.g.
<CODE>SSLv23_server_method()</CODE> and be able to negotiate with all
possible clients, but to only allow newer protocols like SSLv3 or TLSv1.

</P>
<P>
<CODE>SSL_CTX_new()</CODE> initializes the list of ciphers, the session
cache setting, the callbacks, the keys and certificates, and the options to
its default values.

</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>
The creation of a new SSL_CTX object failed. Check the error stack to find
out the reason.

</P>
<DT><STRONG><A NAME="item_Pointer">Pointer to an SSL_CTX object</A></STRONG><DD>
<P>
The return value points to an allocated SSL_CTX object.

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



</P>
:}

