1.\" $OpenBSD: SSL_CTX_set_options.3,v 1.15 2021/06/12 11:02:20 tb 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: June 12 2021 $ 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 RFC 4347 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_DTLSv1 188Do not use the DTLSv1 protocol. 189Deprecated; use 190.Xr SSL_CTX_set_min_proto_version 3 191instead. 192.It Dv SSL_OP_NO_DTLSv1_2 193Do not use the DTLSv1.2 protocol. 194Deprecated; use 195.Xr SSL_CTX_set_min_proto_version 3 196instead. 197.It Dv SSL_OP_NO_QUERY_MTU 198Do not query the MTU. 199Only affects DTLS connections. 200.It Dv SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 201When performing renegotiation as a server, always start a new session (i.e., 202session resumption requests are only accepted in the initial handshake). 203This option is not needed for clients. 204.It Dv SSL_OP_NO_TICKET 205Normally clients and servers using TLSv1.2 and earlier will, where possible, 206transparently make use of 207RFC 5077 tickets for stateless session resumption. 208.Pp 209If this option is set this functionality is disabled and tickets will not be 210used by clients or servers. 211.It Dv SSL_OP_NO_TLSv1 212Do not use the TLSv1.0 protocol. 213Deprecated; use 214.Xr SSL_CTX_set_min_proto_version 3 215instead. 216.It Dv SSL_OP_NO_TLSv1_1 217Do not use the TLSv1.1 protocol. 218Deprecated; use 219.Xr SSL_CTX_set_min_proto_version 3 220instead. 221.It Dv SSL_OP_NO_TLSv1_2 222Do not use the TLSv1.2 protocol. 223Deprecated; use 224.Xr SSL_CTX_set_max_proto_version 3 225instead. 226.El 227.Pp 228The following options used to be supported at some point in the past 229and no longer have any effect: 230.Dv SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION , 231.Dv SSL_OP_EPHEMERAL_RSA , 232.Dv SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER , 233.Dv SSL_OP_MICROSOFT_SESS_ID_BUG , 234.Dv SSL_OP_NETSCAPE_CA_DN_BUG , 235.Dv SSL_OP_NETSCAPE_CHALLENGE_BUG , 236.Dv SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG , 237.Dv SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG , 238.Dv SSL_OP_NO_COMPRESSION , 239.Dv SSL_OP_NO_SSLv2 , 240.Dv SSL_OP_NO_SSLv3 , 241.Dv SSL_OP_PKCS1_CHECK_1 , 242.Dv SSL_OP_PKCS1_CHECK_2 , 243.Dv SSL_OP_SAFARI_ECDHE_ECDSA_BUG , 244.Dv SSL_OP_SINGLE_DH_USE , 245.Dv SSL_OP_SINGLE_ECDH_USE , 246.Dv SSL_OP_SSLEAY_080_CLIENT_DH_BUG , 247.Dv SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG , 248.Dv SSL_OP_TLS_BLOCK_PADDING_BUG , 249.Dv SSL_OP_TLS_D5_BUG , 250.Dv SSL_OP_TLS_ROLLBACK_BUG , 251.Dv SSL_OP_TLSEXT_PADDING . 252.Sh SECURE RENEGOTIATION 253OpenSSL 0.9.8m and later always attempts to use secure renegotiation as 254described in RFC 5746. 255This counters the prefix attack described in CVE-2009-3555 and elsewhere. 256.Pp 257This attack has far-reaching consequences which application writers should be 258aware of. 259In the description below an implementation supporting secure renegotiation is 260referred to as 261.Dq patched . 262A server not supporting secure 263renegotiation is referred to as 264.Dq unpatched . 265.Pp 266The following sections describe the operations permitted by OpenSSL's secure 267renegotiation implementation. 268.Ss Patched client and server 269Connections and renegotiation are always permitted by OpenSSL implementations. 270.Ss Unpatched client and patched OpenSSL server 271The initial connection succeeds but client renegotiation is denied by the 272server with a 273.Em no_renegotiation 274warning alert. 275.Pp 276If the patched OpenSSL server attempts to renegotiate a fatal 277.Em handshake_failure 278alert is sent. 279This is because the server code may be unaware of the unpatched nature of the 280client. 281.Pp 282Note that a bug in OpenSSL clients earlier than 0.9.8m (all of which 283are unpatched) will result in the connection hanging if it receives a 284.Em no_renegotiation 285alert. 286OpenSSL versions 0.9.8m and later will regard a 287.Em no_renegotiation 288alert as fatal and respond with a fatal 289.Em handshake_failure 290alert. 291This is because the OpenSSL API currently has no provision to indicate to an 292application that a renegotiation attempt was refused. 293.Ss Patched OpenSSL client and unpatched server 294If the option 295.Dv SSL_OP_LEGACY_SERVER_CONNECT 296is set then initial connections and renegotiation between patched OpenSSL 297clients and unpatched servers succeeds. 298If neither option is set then initial connections to unpatched servers will 299fail. 300.Pp 301The option 302.Dv SSL_OP_LEGACY_SERVER_CONNECT 303is currently set by default even though it has security implications: 304otherwise it would be impossible to connect to unpatched servers (i.e., all of 305them initially) and this is clearly not acceptable. 306Renegotiation is permitted because this does not add any additional security 307issues: during an attack clients do not see any renegotiations anyway. 308.Pp 309As more servers become patched the option 310.Dv SSL_OP_LEGACY_SERVER_CONNECT 311will 312.Em not 313be set by default in a future version of OpenSSL. 314.Pp 315OpenSSL client applications wishing to ensure they can connect to unpatched 316servers should always 317.Em set 318.Dv SSL_OP_LEGACY_SERVER_CONNECT . 319.Pp 320OpenSSL client applications that want to ensure they can 321.Em not 322connect to unpatched servers (and thus avoid any security issues) should always 323.Em clear 324.Dv SSL_OP_LEGACY_SERVER_CONNECT 325using 326.Fn SSL_CTX_clear_options 327or 328.Fn SSL_clear_options . 329.Sh RETURN VALUES 330.Fn SSL_CTX_set_options 331and 332.Fn SSL_set_options 333return the new options bitmask after adding 334.Fa options . 335.Pp 336.Fn SSL_CTX_clear_options 337and 338.Fn SSL_clear_options 339return the new options bitmask after clearing 340.Fa options . 341.Pp 342.Fn SSL_CTX_get_options 343and 344.Fn SSL_get_options 345return the current bitmask. 346.Pp 347.Fn SSL_get_secure_renegotiation_support 348returns 1 is the peer supports secure renegotiation and 0 if it does not. 349.Sh SEE ALSO 350.Xr openssl 1 , 351.Xr ssl 3 , 352.Xr SSL_clear 3 , 353.Xr SSL_CTX_ctrl 3 , 354.Xr SSL_CTX_set_min_proto_version 3 , 355.Xr SSL_new 3 356.Sh HISTORY 357.Fn SSL_CTX_set_options 358and 359.Fn SSL_set_options 360first appeared in SSLeay 0.9.0 and have been available since 361.Ox 2.4 . 362.Pp 363.Fn SSL_CTX_get_options 364and 365.Fn SSL_get_options 366first appeared in OpenSSL 0.9.2b and have been available since 367.Ox 2.6 . 368.Pp 369.Fn SSL_CTX_clear_options , 370.Fn SSL_clear_options , 371and 372.Fn SSL_get_secure_renegotiation_support 373first appeared in OpenSSL 0.9.8m and have been available since 374.Ox 4.9 . 375