xref: /openbsd-src/lib/libssl/man/SSL_CTX_set_options.3 (revision 46035553bfdd96e63c94e32da0210227ec2e3cf1)
1.\" $OpenBSD: SSL_CTX_set_options.3,v 1.12 2018/04/11 18:05:49 schwarze Exp $
2.\" full merge up to: OpenSSL 7946ab33 Dec 6 17:56:41 2015 +0100
3.\" selective merge up to: OpenSSL edb79c3a Mar 29 10:07:14 2017 +1000
4.\"
5.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>,
6.\" Bodo Moeller <bodo@openssl.org>, and
7.\" Dr. Stephen Henson <steve@openssl.org>.
8.\" Copyright (c) 2001-2003, 2005, 2007, 2009, 2010, 2013-2015
9.\" The OpenSSL Project.  All rights reserved.
10.\"
11.\" Redistribution and use in source and binary forms, with or without
12.\" modification, are permitted provided that the following conditions
13.\" are met:
14.\"
15.\" 1. Redistributions of source code must retain the above copyright
16.\"    notice, this list of conditions and the following disclaimer.
17.\"
18.\" 2. Redistributions in binary form must reproduce the above copyright
19.\"    notice, this list of conditions and the following disclaimer in
20.\"    the documentation and/or other materials provided with the
21.\"    distribution.
22.\"
23.\" 3. All advertising materials mentioning features or use of this
24.\"    software must display the following acknowledgment:
25.\"    "This product includes software developed by the OpenSSL Project
26.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
27.\"
28.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
29.\"    endorse or promote products derived from this software without
30.\"    prior written permission. For written permission, please contact
31.\"    openssl-core@openssl.org.
32.\"
33.\" 5. Products derived from this software may not be called "OpenSSL"
34.\"    nor may "OpenSSL" appear in their names without prior written
35.\"    permission of the OpenSSL Project.
36.\"
37.\" 6. Redistributions of any form whatsoever must retain the following
38.\"    acknowledgment:
39.\"    "This product includes software developed by the OpenSSL Project
40.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
41.\"
42.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
43.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
46.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\"
55.Dd $Mdocdate: April 11 2018 $
56.Dt SSL_CTX_SET_OPTIONS 3
57.Os
58.Sh NAME
59.Nm SSL_CTX_set_options ,
60.Nm SSL_set_options ,
61.Nm SSL_CTX_clear_options ,
62.Nm SSL_clear_options ,
63.Nm SSL_CTX_get_options ,
64.Nm SSL_get_options ,
65.Nm SSL_get_secure_renegotiation_support
66.Nd manipulate SSL options
67.Sh SYNOPSIS
68.In openssl/ssl.h
69.Ft long
70.Fn SSL_CTX_set_options "SSL_CTX *ctx" "long options"
71.Ft long
72.Fn SSL_set_options "SSL *ssl" "long options"
73.Ft long
74.Fn SSL_CTX_clear_options "SSL_CTX *ctx" "long options"
75.Ft long
76.Fn SSL_clear_options "SSL *ssl" "long options"
77.Ft long
78.Fn SSL_CTX_get_options "SSL_CTX *ctx"
79.Ft long
80.Fn SSL_get_options "SSL *ssl"
81.Ft long
82.Fn SSL_get_secure_renegotiation_support "SSL *ssl"
83.Sh DESCRIPTION
84.Fn SSL_CTX_set_options
85adds the options set via bitmask in
86.Fa options
87to
88.Fa ctx .
89Options already set before are not cleared!
90.Pp
91.Fn SSL_set_options
92adds the options set via bitmask in
93.Fa options
94to
95.Fa ssl .
96Options already set before are not cleared!
97.Pp
98.Fn SSL_CTX_clear_options
99clears the options set via bitmask in
100.Fa options
101to
102.Fa ctx .
103.Pp
104.Fn SSL_clear_options
105clears the options set via bitmask in
106.Fa options
107to
108.Fa ssl .
109.Pp
110.Fn SSL_CTX_get_options
111returns the options set for
112.Fa ctx .
113.Pp
114.Fn SSL_get_options
115returns the options set for
116.Fa ssl .
117.Pp
118.Fn SSL_get_secure_renegotiation_support
119indicates whether the peer supports secure renegotiation.
120.Pp
121All these functions are implemented using macros.
122.Pp
123The behaviour of the SSL library can be changed by setting several options.
124The options are coded as bitmasks and can be combined by a bitwise OR
125operation (|).
126.Pp
127.Fn SSL_CTX_set_options
128and
129.Fn SSL_set_options
130affect the (external) protocol behaviour of the SSL library.
131The (internal) behaviour of the API can be changed by using the similar
132.Xr SSL_CTX_set_mode 3
133and
134.Xr SSL_set_mode 3
135functions.
136.Pp
137During a handshake, the option settings of the SSL object are used.
138When a new SSL object is created from a context using
139.Xr SSL_new 3 ,
140the current option setting is copied.
141Changes to
142.Fa ctx
143do not affect already created
144.Vt SSL
145objects.
146.Fn SSL_clear
147does not affect the settings.
148.Pp
149The following
150.Em bug workaround
151options are available:
152.Bl -tag -width Ds
153.It Dv SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
154Disables a countermeasure against a TLS 1.0 protocol vulnerability
155affecting CBC ciphers, which cannot be handled by some broken SSL
156implementations.
157This option has no effect for connections using other ciphers.
158.It Dv SSL_OP_ALL
159This is currently an alias for
160.Dv SSL_OP_LEGACY_SERVER_CONNECT .
161.El
162.Pp
163It is usually safe to use
164.Dv SSL_OP_ALL
165to enable the bug workaround options if compatibility with somewhat broken
166implementations is desired.
167.Pp
168The following
169.Em modifying
170options are available:
171.Bl -tag -width Ds
172.It Dv SSL_OP_CIPHER_SERVER_PREFERENCE
173When choosing a cipher, use the server's preferences instead of the client
174preferences.
175When not set, the server will always follow the client's preferences.
176When set, the server will choose following its own preferences.
177.It Dv SSL_OP_COOKIE_EXCHANGE
178Turn on Cookie Exchange as described in RFC4347 Section 4.2.1.
179Only affects DTLS connections.
180.It Dv SSL_OP_LEGACY_SERVER_CONNECT
181Allow legacy insecure renegotiation between OpenSSL and unpatched servers
182.Em only :
183this option is currently set by default.
184See the
185.Sx SECURE RENEGOTIATION
186section for more details.
187.It Dv SSL_OP_NO_QUERY_MTU
188Do not query the MTU.
189Only affects DTLS connections.
190.It Dv SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
191When performing renegotiation as a server, always start a new session (i.e.,
192session resumption requests are only accepted in the initial handshake).
193This option is not needed for clients.
194.It Dv SSL_OP_NO_TICKET
195Normally clients and servers will, where possible, transparently make use of
196RFC4507bis tickets for stateless session resumption.
197.Pp
198If this option is set this functionality is disabled and tickets will not be
199used by clients or servers.
200.It Dv SSL_OP_NO_TLSv1
201Do not use the TLSv1.0 protocol.
202Deprecated; use
203.Xr SSL_CTX_set_min_proto_version 3
204instead.
205.It Dv SSL_OP_NO_TLSv1_1
206Do not use the TLSv1.1 protocol.
207.It Dv SSL_OP_NO_TLSv1_2
208Do not use the TLSv1.2 protocol.
209Deprecated; use
210.Xr SSL_CTX_set_max_proto_version 3
211instead.
212.El
213.Pp
214The following options used to be supported at some point in the past
215and no longer have any effect:
216.Dv SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION ,
217.Dv SSL_OP_EPHEMERAL_RSA ,
218.Dv SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER ,
219.Dv SSL_OP_MICROSOFT_SESS_ID_BUG ,
220.Dv SSL_OP_NETSCAPE_CA_DN_BUG ,
221.Dv SSL_OP_NETSCAPE_CHALLENGE_BUG ,
222.Dv SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG ,
223.Dv SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG ,
224.Dv SSL_OP_NO_COMPRESSION ,
225.Dv SSL_OP_NO_SSLv2 ,
226.Dv SSL_OP_NO_SSLv3 ,
227.Dv SSL_OP_PKCS1_CHECK_1 ,
228.Dv SSL_OP_PKCS1_CHECK_2 ,
229.Dv SSL_OP_SAFARI_ECDHE_ECDSA_BUG ,
230.Dv SSL_OP_SINGLE_DH_USE ,
231.Dv SSL_OP_SINGLE_ECDH_USE ,
232.Dv SSL_OP_SSLEAY_080_CLIENT_DH_BUG ,
233.Dv SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG ,
234.Dv SSL_OP_TLS_BLOCK_PADDING_BUG ,
235.Dv SSL_OP_TLS_D5_BUG ,
236.Dv SSL_OP_TLS_ROLLBACK_BUG ,
237.Dv SSL_OP_TLSEXT_PADDING .
238.Sh SECURE RENEGOTIATION
239OpenSSL 0.9.8m and later always attempts to use secure renegotiation as
240described in RFC5746.
241This counters the prefix attack described in CVE-2009-3555 and elsewhere.
242.Pp
243This attack has far-reaching consequences which application writers should be
244aware of.
245In the description below an implementation supporting secure renegotiation is
246referred to as
247.Dq patched .
248A server not supporting secure
249renegotiation is referred to as
250.Dq unpatched .
251.Pp
252The following sections describe the operations permitted by OpenSSL's secure
253renegotiation implementation.
254.Ss Patched client and server
255Connections and renegotiation are always permitted by OpenSSL implementations.
256.Ss Unpatched client and patched OpenSSL server
257The initial connection succeeds but client renegotiation is denied by the
258server with a
259.Em no_renegotiation
260warning alert.
261.Pp
262If the patched OpenSSL server attempts to renegotiate a fatal
263.Em handshake_failure
264alert is sent.
265This is because the server code may be unaware of the unpatched nature of the
266client.
267.Pp
268Note that a bug in OpenSSL clients earlier than 0.9.8m (all of which
269are unpatched) will result in the connection hanging if it receives a
270.Em no_renegotiation
271alert.
272OpenSSL versions 0.9.8m and later will regard a
273.Em no_renegotiation
274alert as fatal and respond with a fatal
275.Em handshake_failure
276alert.
277This is because the OpenSSL API currently has no provision to indicate to an
278application that a renegotiation attempt was refused.
279.Ss Patched OpenSSL client and unpatched server
280If the option
281.Dv SSL_OP_LEGACY_SERVER_CONNECT
282is set then initial connections and renegotiation between patched OpenSSL
283clients and unpatched servers succeeds.
284If neither option is set then initial connections to unpatched servers will
285fail.
286.Pp
287The option
288.Dv SSL_OP_LEGACY_SERVER_CONNECT
289is currently set by default even though it has security implications:
290otherwise it would be impossible to connect to unpatched servers (i.e., all of
291them initially) and this is clearly not acceptable.
292Renegotiation is permitted because this does not add any additional security
293issues: during an attack clients do not see any renegotiations anyway.
294.Pp
295As more servers become patched the option
296.Dv SSL_OP_LEGACY_SERVER_CONNECT
297will
298.Em not
299be set by default in a future version of OpenSSL.
300.Pp
301OpenSSL client applications wishing to ensure they can connect to unpatched
302servers should always
303.Em set
304.Dv SSL_OP_LEGACY_SERVER_CONNECT .
305.Pp
306OpenSSL client applications that want to ensure they can
307.Em not
308connect to unpatched servers (and thus avoid any security issues) should always
309.Em clear
310.Dv SSL_OP_LEGACY_SERVER_CONNECT
311using
312.Fn SSL_CTX_clear_options
313or
314.Fn SSL_clear_options .
315.Sh RETURN VALUES
316.Fn SSL_CTX_set_options
317and
318.Fn SSL_set_options
319return the new options bitmask after adding
320.Fa options .
321.Pp
322.Fn SSL_CTX_clear_options
323and
324.Fn SSL_clear_options
325return the new options bitmask after clearing
326.Fa options .
327.Pp
328.Fn SSL_CTX_get_options
329and
330.Fn SSL_get_options
331return the current bitmask.
332.Pp
333.Fn SSL_get_secure_renegotiation_support
334returns 1 is the peer supports secure renegotiation and 0 if it does not.
335.Sh SEE ALSO
336.Xr openssl 1 ,
337.Xr ssl 3 ,
338.Xr SSL_clear 3 ,
339.Xr SSL_CTX_ctrl 3 ,
340.Xr SSL_CTX_set_min_proto_version 3 ,
341.Xr SSL_new 3
342.Sh HISTORY
343.Fn SSL_CTX_set_options
344and
345.Fn SSL_set_options
346first appeared in SSLeay 0.9.0 and have been available since
347.Ox 2.4 .
348.Pp
349.Fn SSL_CTX_get_options
350and
351.Fn SSL_get_options
352first appeared in OpenSSL 0.9.2b and have been available since
353.Ox 2.6 .
354.Pp
355.Fn SSL_CTX_clear_options ,
356.Fn SSL_clear_options ,
357and
358.Fn SSL_get_secure_renegotiation_support
359first appeared in OpenSSL 0.9.8m and have been available since
360.Ox 4.9 .
361