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