5 SSL_CTX_new, SSL_CTX_up_ref, SSLv3_method, SSLv3_server_method,
6 SSLv3_client_method, TLSv1_method, TLSv1_server_method, TLSv1_client_method,
7 TLSv1_1_method, TLSv1_1_server_method, TLSv1_1_client_method, TLS_method,
8 TLS_server_method, TLS_client_method, SSLv23_method, SSLv23_server_method,
9 SSLv23_client_method, DTLS_method, DTLS_server_method, DTLS_client_method,
10 DTLSv1_method, DTLSv1_server_method, DTLSv1_client_method,
11 DTLSv1_2_method, DTLSv1_2_server_method, DTLSv1_2_client_method -
12 create a new SSL_CTX object as framework for TLS/SSL or DTLS enabled
17 #include <openssl/ssl.h>
19 SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
20 int SSL_CTX_up_ref(SSL_CTX *ctx);
22 const SSL_METHOD *TLS_method(void);
23 const SSL_METHOD *TLS_server_method(void);
24 const SSL_METHOD *TLS_client_method(void);
26 #define SSLv23_method TLS_method
27 #define SSLv23_server_method TLS_server_method
28 #define SSLv23_client_method TLS_client_method
30 #ifndef OPENSSL_NO_SSL3_METHOD
31 const SSL_METHOD *SSLv3_method(void);
32 const SSL_METHOD *SSLv3_server_method(void);
33 const SSL_METHOD *SSLv3_client_method(void);
36 #ifndef OPENSSL_NO_TLS1_METHOD
37 const SSL_METHOD *TLSv1_method(void);
38 const SSL_METHOD *TLSv1_server_method(void);
39 const SSL_METHOD *TLSv1_client_method(void);
42 #ifndef OPENSSL_NO_TLS1_1_METHOD
43 const SSL_METHOD *TLSv1_1_method(void);
44 const SSL_METHOD *TLSv1_1_server_method(void);
45 const SSL_METHOD *TLSv1_1_client_method(void);
48 #ifndef OPENSSL_NO_TLS1_2_METHOD
49 const SSL_METHOD *TLSv1_2_method(void);
50 const SSL_METHOD *TLSv1_2_server_method(void);
51 const SSL_METHOD *TLSv1_2_client_method(void);
54 const SSL_METHOD *DTLS_method(void);
55 const SSL_METHOD *DTLS_server_method(void);
56 const SSL_METHOD *DTLS_client_method(void);
58 #ifndef OPENSSL_NO_DTLS1_METHOD
59 const SSL_METHOD *DTLSv1_method(void);
60 const SSL_METHOD *DTLSv1_server_method(void);
61 const SSL_METHOD *DTLSv1_client_method(void);
64 #ifndef OPENSSL_NO_DTLS1_2_METHOD
65 const SSL_METHOD *DTLSv1_2_method(void);
66 const SSL_METHOD *DTLSv1_2_server_method(void);
67 const SSL_METHOD *DTLSv1_2_client_method(void);
72 SSL_CTX_new() creates a new B<SSL_CTX> object as framework to
73 establish TLS/SSL or DTLS enabled connections. An B<SSL_CTX> object is
74 reference counted. Creating an B<SSL_CTX> object for the first time increments
75 the reference count. Freeing it (using SSL_CTX_free) decrements it. When the
76 reference count drops to zero, any memory or resources allocated to the
77 B<SSL_CTX> object are freed. SSL_CTX_up_ref() increments the reference count for
78 an existing B<SSL_CTX> structure.
82 The SSL_CTX object uses B<method> as connection method.
83 The methods exist in a generic type (for client and server use), a server only
84 type, and a client only type.
85 B<method> can be of the following types:
89 =item TLS_method(), TLS_server_method(), TLS_client_method()
91 These are the general-purpose I<version-flexible> SSL/TLS methods.
92 The actual protocol version used will be negotiated to the highest version
93 mutually supported by the client and the server.
94 The supported protocols are SSLv3, TLSv1, TLSv1.1 and TLSv1.2.
95 Applications should use these methods, and avoid the version-specific
96 methods described below.
98 =item SSLv23_method(), SSLv23_server_method(), SSLv23_client_method()
100 Use of these functions is deprecated. They have been replaced with the above
101 TLS_method(), TLS_server_method() and TLS_client_method() respectively. New
102 code should use those functions instead.
104 =item TLSv1_2_method(), TLSv1_2_server_method(), TLSv1_2_client_method()
106 A TLS/SSL connection established with these methods will only understand the
109 =item TLSv1_1_method(), TLSv1_1_server_method(), TLSv1_1_client_method()
111 A TLS/SSL connection established with these methods will only understand the
114 =item TLSv1_method(), TLSv1_server_method(), TLSv1_client_method()
116 A TLS/SSL connection established with these methods will only understand the
119 =item SSLv3_method(), SSLv3_server_method(), SSLv3_client_method()
121 A TLS/SSL connection established with these methods will only understand the
123 The SSLv3 protocol is deprecated and should not be used.
125 =item DTLS_method(), DTLS_server_method(), DTLS_client_method()
127 These are the version-flexible DTLS methods.
128 Currently supported protocols are DTLS 1.0 and DTLS 1.2.
130 =item DTLSv1_2_method(), DTLSv1_2_server_method(), DTLSv1_2_client_method()
132 These are the version-specific methods for DTLSv1.2.
134 =item DTLSv1_method(), DTLSv1_server_method(), DTLSv1_client_method()
136 These are the version-specific methods for DTLSv1.
140 SSL_CTX_new() initializes the list of ciphers, the session cache setting, the
141 callbacks, the keys and certificates and the options to their default values.
143 TLS_method(), TLS_server_method(), TLS_client_method(), DTLS_method(),
144 DTLS_server_method() and DTLS_client_method() are the I<version-flexible>
146 All other methods only support one specific protocol version.
147 Use the I<version-flexible> methods instead of the version specific methods.
149 If you want to limit the supported protocols for the version flexible
150 methods you can use L<SSL_CTX_set_min_proto_version(3)>,
151 L<SSL_set_min_proto_version(3)>, L<SSL_CTX_set_max_proto_version(3)> and
152 LSSL_set_max_proto_version(3)> functions.
153 Using these functions it is possible to choose e.g. TLS_server_method()
154 and be able to negotiate with all possible clients, but to only
155 allow newer protocols like TLS 1.0, TLS 1.1 or TLS 1.2.
157 The list of protocols available can also be limited using the
158 B<SSL_OP_NO_SSLv3>, B<SSL_OP_NO_TLSv1>, B<SSL_OP_NO_TLSv1_1> and
159 B<SSL_OP_NO_TLSv1_2> options of the L<SSL_CTX_set_options(3)> or
160 L<SSL_set_options(3)> functions, but this approach is not recommended.
161 Clients should avoid creating "holes" in the set of protocols they support.
162 When disabling a protocol, make sure that you also disable either all previous
163 or all subsequent protocol versions.
164 In clients, when a protocol version is disabled without disabling I<all>
165 previous protocol versions, the effect is to also disable all subsequent
168 The SSLv3 protocol is deprecated and should generally not be used.
169 Applications should typically use L<SSL_CTX_set_min_proto_version(3)> to set
170 the minimum protocol to at least B<TLS1_VERSION>.
174 The following return values can occur:
180 The creation of a new SSL_CTX object failed. Check the error stack to find out
183 =item Pointer to an SSL_CTX object
185 The return value points to an allocated SSL_CTX object.
187 SSL_CTX_up_ref() returns 1 for success and 0 for failure.
193 Support for SSLv2 and the corresponding SSLv2_method(),
194 SSLv2_server_method() and SSLv2_client_method() functions where
195 removed in OpenSSL 1.1.0.
197 SSLv23_method(), SSLv23_server_method() and SSLv23_client_method()
198 were deprecated and the preferred TLS_method(), TLS_server_method()
199 and TLS_client_method() functions were introduced in OpenSSL 1.1.0.
201 All version-specific methods were deprecated in OpenSSL 1.1.0.
205 L<SSL_CTX_set_options(3)>, L<SSL_CTX_free(3)>, L<SSL_accept(3)>,
206 L<SSL_CTX_set_min_proto_version(3)>, L<ssl(3)>, L<SSL_set_connect_state(3)>