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