136f97b366bb4878849573e3f522d2b65e5b8793
[openssl.git] / doc / ssl / SSL_CTX_new.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_new, SSLv3_method, SSLv3_server_method, SSLv3_client_method,
6 TLSv1_method, TLSv1_server_method, TLSv1_client_method, TLSv1_1_method,
7 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
13 functions
14
15 =head1 SYNOPSIS
16
17  #include <openssl/ssl.h>
18
19  SSL_CTX *SSL_CTX_new(const SSL_METHOD *method);
20
21  const SSL_METHOD *TLS_method(void);
22  const SSL_METHOD *TLS_server_method(void);
23  const SSL_METHOD *TLS_client_method(void);
24
25  #define SSLv23_method           TLS_method
26  #define SSLv23_server_method    TLS_server_method
27  #define SSLv23_client_method    TLS_client_method
28
29  #ifndef OPENSSL_NO_SSL3_METHOD
30  const SSL_METHOD *SSLv3_method(void);
31  const SSL_METHOD *SSLv3_server_method(void);
32  const SSL_METHOD *SSLv3_client_method(void);
33  #endif
34
35  const SSL_METHOD *TLSv1_method(void);
36  const SSL_METHOD *TLSv1_server_method(void);
37  const SSL_METHOD *TLSv1_client_method(void);
38
39  const SSL_METHOD *TLSv1_1_method(void);
40  const SSL_METHOD *TLSv1_1_server_method(void);
41  const SSL_METHOD *TLSv1_1_client_method(void);
42
43  const SSL_METHOD *TLSv1_2_method(void);
44  const SSL_METHOD *TLSv1_2_server_method(void);
45  const SSL_METHOD *TLSv1_2_client_method(void);
46
47  const SSL_METHOD *DTLS_method(void);
48  const SSL_METHOD *DTLS_server_method(void);
49  const SSL_METHOD *DTLS_client_method(void);
50
51  const SSL_METHOD *DTLSv1_method(void);
52  const SSL_METHOD *DTLSv1_server_method(void);
53  const SSL_METHOD *DTLSv1_client_method(void);
54
55  const SSL_METHOD *DTLSv1_2_method(void);
56  const SSL_METHOD *DTLSv1_2_server_method(void);
57  const SSL_METHOD *DTLSv1_2_client_method(void);
58
59 =head1 DESCRIPTION
60
61 SSL_CTX_new() creates a new B<SSL_CTX> object as framework to
62 establish TLS/SSL or DTLS enabled connections.
63
64 =head1 NOTES
65
66 The SSL_CTX object uses B<method> as connection method.
67 The methods exist in a generic type (for client and server use), a server only
68 type, and a client only type.
69 B<method> can be of the following types:
70
71 =over 4
72
73 =item SSLv3_method(), SSLv3_server_method(), SSLv3_client_method()
74
75 An SSL connection established with these methods will only understand
76 the SSLv3 protocol.
77 A client will send out a SSLv3 client hello messages and will
78 indicate that it supports SSLv3.
79 A server will only understand SSLv3 client hello message and only
80 support the SSLv3 protocol.
81
82 =item TLSv1_method(), TLSv1_server_method(), TLSv1_client_method()
83
84 A TLS connection established with these methods will only understand
85 the TLS 1.0 protocol.
86
87 =item TLSv1_1_method(), TLSv1_1_server_method(), TLSv1_1_client_method()
88
89 A TLS connection established with these methods will only understand
90 the TLS 1.1 protocol.
91
92 =item TLSv1_2_method(), TLSv1_2_server_method(), TLSv1_2_client_method()
93
94 A TLS connection established with these methods will only understand
95 the TLS 1.2 protocol.
96
97 =item TLS_method(), TLS_server_method(), TLS_client_method()
98
99 A TLS/SSL connection established with these methods may understand
100 the SSLv3, TLSv1, TLSv1.1 and TLSv1.2 protocols.
101
102 If extensions are required (for example server name)
103 a client will send out TLSv1 client hello messages including extensions and
104 will indicate that it also understands TLSv1.1, TLSv1.2 and permits a
105 fallback to SSLv3. A server will support SSLv3, TLSv1, TLSv1.1 and TLSv1.2
106 protocols. This is the best choice when compatibility is a concern.
107
108 =item SSLv23_method(), SSLv23_server_method(), SSLv23_client_method()
109
110 Use of these functions is deprecated. They have been replaced with TLS_method(),
111 TLS_server_method() and TLS_client_method() respectively. New code should use
112 those functions instead.
113
114 =item DTLS_method(), DTLS_server_method(), DTLS_client_method()
115
116 A DTLS connection established with those methods understands all
117 supported DTLS protocols.
118 Currently supported protocols are DTLS 1.0 and DTLS 1.2.
119
120 =item DTLSv1_method(), DTLSv1_server_method(), DTLSv1_client_method()
121
122 A DTLS connection established with these methods will only understand
123 the DTLS 1.0 protocol.
124
125 =item DTLSv1_2_method(), DTLSv1_2_server_method(), DTLSv1_2_client_method()
126
127 A DTLS connection established with these methods will only understand
128 the DTLS 1.2 protocol.
129
130 =back
131
132 TLS_method(), TLS_server_method(), TLS_client_method(), DTLS_method(),
133 DTLS_server_method() and DTLS_client_method() are the version
134 flexible methods.
135 All other methods only support one specific protocol version.
136 Use these methods instead of the other version specific methods.
137
138 If you want to limit the supported protocols for the version flexible
139 methods you can use SSL_CTX_set_min_proto_version(),
140 SSL_set_min_proto_version(), SSL_CTX_set_max_proto_version() and
141 SSL_set_max_proto_version() functions.
142 They can also be limited using by using an option like SSL_OP_NO_SSLv3
143 of the SSL_CTX_set_options() or SSL_set_options() functions, but
144 that's not recommended.
145 Using these functions it is possible to choose e.g. TLS_server_method()
146 and be able to negotiate with all possible clients, but to only
147 allow newer protocols like TLS 1.0, TLS 1.1 or TLS 1.2.
148
149 SSL_CTX_new() initializes the list of ciphers, the session cache
150 setting, the callbacks, the keys and certificates and the options
151 to its default values.
152
153 =head1 RETURN VALUES
154
155 The following return values can occur:
156
157 =over 4
158
159 =item NULL
160
161 The creation of a new SSL_CTX object failed. Check the error stack to
162 find out the reason.
163
164 =item Pointer to an SSL_CTX object
165
166 The return value points to an allocated SSL_CTX object.
167
168 =back
169
170 =head1 HISTORY
171
172 Support for SSLv2 and the corresponding SSLv2_method(),
173 SSLv2_server_method() and SSLv2_client_method() functions where
174 removed in OpenSSL 1.1.0.
175
176 SSLv23_method(), SSLv23_server_method() and SSLv23_client_method()
177 were deprecated and the preferred TLS_method(), TLS_server_method()
178 and TLS_client_method() functions were introduced in OpenSSL 1.1.0.
179
180 =head1 SEE ALSO
181
182 L<SSL_CTX_free(3)>, L<SSL_accept(3)>,
183 L<SSL_CTX_set_min_proto_version(3)>,
184 L<ssl(3)>,  L<SSL_set_connect_state(3)>
185
186 =cut