VirtualBox

source: vbox/trunk/src/libs/openssl-3.3.2/doc/man3/SSL_CTX_set_options.pod

Last change on this file was 108206, checked in by vboxsync, 3 months ago

openssl-3.3.2: Exported all files to OSE and removed .scm-settings ​bugref:10757

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.5 KB
Line 
1=pod
2
3=head1 NAME
4
5SSL_CTX_set_options, SSL_set_options, SSL_CTX_clear_options,
6SSL_clear_options, SSL_CTX_get_options, SSL_get_options,
7SSL_get_secure_renegotiation_support - manipulate SSL options
8
9=head1 SYNOPSIS
10
11 #include <openssl/ssl.h>
12
13 uint64_t SSL_CTX_set_options(SSL_CTX *ctx, uint64_t options);
14 uint64_t SSL_set_options(SSL *ssl, uint64_t options);
15
16 uint64_t SSL_CTX_clear_options(SSL_CTX *ctx, uint64_t options);
17 uint64_t SSL_clear_options(SSL *ssl, uint64_t options);
18
19 uint64_t SSL_CTX_get_options(const SSL_CTX *ctx);
20 uint64_t SSL_get_options(const SSL *ssl);
21
22 long SSL_get_secure_renegotiation_support(SSL *ssl);
23
24=head1 DESCRIPTION
25
26SSL_CTX_set_options() adds the options set via bit-mask in B<options> to B<ctx>.
27Options already set before are not cleared!
28
29SSL_set_options() adds the options set via bit-mask in B<options> to B<ssl>.
30Options already set before are not cleared!
31
32SSL_CTX_clear_options() clears the options set via bit-mask in B<options>
33to B<ctx>.
34
35SSL_clear_options() clears the options set via bit-mask in B<options> to B<ssl>.
36
37SSL_CTX_get_options() returns the options set for B<ctx>.
38
39SSL_get_options() returns the options set for B<ssl>.
40
41SSL_get_secure_renegotiation_support() indicates whether the peer supports
42secure renegotiation.
43Note, this is implemented via a macro.
44
45=head1 NOTES
46
47The behaviour of the SSL library can be changed by setting several options.
48The options are coded as bit-masks and can be combined by a bitwise B<or>
49operation (|).
50
51SSL_CTX_set_options() and SSL_set_options() affect the (external)
52protocol behaviour of the SSL library. The (internal) behaviour of
53the API can be changed by using the similar
54L<SSL_CTX_set_mode(3)> and SSL_set_mode() functions.
55
56During a handshake, the option settings of the SSL object are used. When
57a new SSL object is created from a context using SSL_new(), the current
58option setting is copied. Changes to B<ctx> do not affect already created
59SSL objects. SSL_clear() does not affect the settings.
60
61The following B<bug workaround> options are available:
62
63=over 4
64
65=item SSL_OP_CRYPTOPRO_TLSEXT_BUG
66
67Add server-hello extension from the early version of cryptopro draft
68when GOST ciphersuite is negotiated. Required for interoperability with CryptoPro
69CSP 3.x.
70
71=item SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
72
73Disables a countermeasure against a SSL 3.0/TLS 1.0 protocol
74vulnerability affecting CBC ciphers, which cannot be handled by some
75broken SSL implementations. This option has no effect for connections
76using other ciphers.
77
78=item SSL_OP_SAFARI_ECDHE_ECDSA_BUG
79
80Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X.
81OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.
82
83=item SSL_OP_TLSEXT_PADDING
84
85Adds a padding extension to ensure the ClientHello size is never between
86256 and 511 bytes in length. This is needed as a workaround for some
87implementations.
88
89=item SSL_OP_ALL
90
91All of the above bug workarounds.
92
93=back
94
95It is usually safe to use B<SSL_OP_ALL> to enable the bug workaround
96options if compatibility with somewhat broken implementations is
97desired.
98
99The following B<modifying> options are available:
100
101=over 4
102
103=item SSL_OP_ALLOW_CLIENT_RENEGOTIATION
104
105Client-initiated renegotiation is disabled by default. Use
106this option to enable it.
107
108=item SSL_OP_ALLOW_NO_DHE_KEX
109
110In TLSv1.3 allow a non-(ec)dhe based key exchange mode on resumption. This means
111that there will be no forward secrecy for the resumed session.
112
113=item SSL_OP_PREFER_NO_DHE_KEX
114
115In TLSv1.3, on resumption let the server prefer a non-(ec)dhe based key
116exchange mode over an (ec)dhe based one. Ignored without B<SSL_OP_ALLOW_NO_DHE_KEX>
117being set as well. Always ignored on the client.
118
119=item SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
120
121Allow legacy insecure renegotiation between OpenSSL and unpatched clients or
122servers. See the B<SECURE RENEGOTIATION> section for more details.
123
124=item SSL_OP_CIPHER_SERVER_PREFERENCE
125
126When choosing a cipher, use the server's preferences instead of the client
127preferences. When not set, the SSL server will always follow the clients
128preferences. When set, the SSL/TLS server will choose following its
129own preferences.
130
131=item SSL_OP_CISCO_ANYCONNECT
132
133Use Cisco's version identifier of DTLS_BAD_VER when establishing a DTLSv1
134connection. Only available when using the deprecated DTLSv1_client_method() API.
135
136=item SSL_OP_CLEANSE_PLAINTEXT
137
138By default TLS and QUIC SSL objects keep a copy of received plaintext
139application data in a static buffer until it is overwritten by the
140next portion of data. When enabling SSL_OP_CLEANSE_PLAINTEXT
141deciphered application data is cleansed by calling OPENSSL_cleanse(3)
142after passing data to the application. Data is also cleansed when
143releasing the connection (e.g. L<SSL_free(3)>).
144
145Since OpenSSL only cleanses internal buffers, the application is still
146responsible for cleansing all other buffers. Most notably, this
147applies to buffers passed to functions like L<SSL_read(3)>,
148L<SSL_peek(3)> but also like L<SSL_write(3)>.
149
150TLS connections do not buffer data to be sent in plaintext. QUIC stream
151objects do buffer plaintext data to be sent and this option will also cause
152that data to be cleansed when it is discarded.
153
154This option can be set differently on individual QUIC stream objects and
155has no effect on QUIC connection objects (except where a default stream is
156being used).
157
158=item SSL_OP_COOKIE_EXCHANGE
159
160Turn on Cookie Exchange as described in RFC4347 Section 4.2.1. Only affects
161DTLS connections.
162
163=item SSL_OP_DISABLE_TLSEXT_CA_NAMES
164
165Disable TLS Extension CA Names. You may want to disable it for security reasons
166or for compatibility with some Windows TLS implementations crashing when this
167extension is larger than 1024 bytes.
168
169=item SSL_OP_ENABLE_KTLS
170
171Enable the use of kernel TLS. In order to benefit from kernel TLS OpenSSL must
172have been compiled with support for it, and it must be supported by the
173negotiated ciphersuites and extensions. The specific ciphersuites and extensions
174that are supported may vary by platform and kernel version.
175
176The kernel TLS data-path implements the record layer, and the encryption
177algorithm. The kernel will utilize the best hardware
178available for encryption. Using the kernel data-path should reduce the memory
179footprint of OpenSSL because no buffering is required. Also, the throughput
180should improve because data copy is avoided when user data is encrypted into
181kernel memory instead of the usual encrypt then copy to kernel.
182
183Kernel TLS might not support all the features of OpenSSL. For instance,
184renegotiation, and setting the maximum fragment size is not possible as of
185Linux 4.20.
186
187Note that with kernel TLS enabled some cryptographic operations are performed
188by the kernel directly and not via any available OpenSSL Providers. This might
189be undesirable if, for example, the application requires all cryptographic
190operations to be performed by the FIPS provider.
191
192=item SSL_OP_ENABLE_KTLS_TX_ZEROCOPY_SENDFILE
193
194With this option, sendfile() will use the zerocopy mode, which gives a
195performance boost when used with KTLS hardware offload. Note that invalid TLS
196records might be transmitted if the file is changed while being sent. This
197option has no effect if B<SSL_OP_ENABLE_KTLS> is not enabled.
198
199This option only applies to Linux. KTLS sendfile on FreeBSD doesn't offer an
200option to disable zerocopy and always runs in this mode.
201
202=item SSL_OP_ENABLE_MIDDLEBOX_COMPAT
203
204If set then dummy Change Cipher Spec (CCS) messages are sent in TLSv1.3. This
205has the effect of making TLSv1.3 look more like TLSv1.2 so that middleboxes that
206do not understand TLSv1.3 will not drop the connection. Regardless of whether
207this option is set or not CCS messages received from the peer will always be
208ignored in TLSv1.3. This option is set by default. To switch it off use
209SSL_clear_options(). A future version of OpenSSL may not set this by default.
210
211=item SSL_OP_IGNORE_UNEXPECTED_EOF
212
213Some TLS implementations do not send the mandatory close_notify alert on
214shutdown. If the application tries to wait for the close_notify alert but the
215peer closes the connection without sending it, an error is generated. When this
216option is enabled the peer does not need to send the close_notify alert and a
217closed connection will be treated as if the close_notify alert was received.
218
219You should only enable this option if the protocol running over TLS
220can detect a truncation attack itself, and that the application is checking for
221that truncation attack.
222
223For more information on shutting down a connection, see L<SSL_shutdown(3)>.
224
225=item SSL_OP_LEGACY_SERVER_CONNECT
226
227Allow legacy insecure renegotiation between OpenSSL and unpatched servers
228B<only>. See the B<SECURE RENEGOTIATION> section for more details.
229
230=item SSL_OP_NO_ANTI_REPLAY
231
232By default, when a server is configured for early data (i.e., max_early_data > 0),
233OpenSSL will switch on replay protection. See L<SSL_read_early_data(3)> for a
234description of the replay protection feature. Anti-replay measures are required
235to comply with the TLSv1.3 specification. Some applications may be able to
236mitigate the replay risks in other ways and in such cases the built in OpenSSL
237functionality is not required. Those applications can turn this feature off by
238setting this option. This is a server-side option only. It is ignored by
239clients.
240
241=item SSL_OP_NO_TX_CERTIFICATE_COMPRESSION
242
243Normally clients and servers will transparently attempt to negotiate the
244RFC8879 certificate compression option on TLSv1.3 connections.
245
246If this option is set, the certificate compression extension is ignored
247upon receipt and compressed certificates will not be sent to the peer.
248
249=item SSL_OP_NO_RX_CERTIFICATE_COMPRESSION
250
251Normally clients and servers will transparently attempt to negotiate the
252RFC8879 certificate compression option on TLSv1.3 connections.
253
254If this option is set, the certificate compression extension will not be sent
255and compressed certificates will not be accepted from the peer.
256
257=item SSL_OP_NO_COMPRESSION
258
259Do not use TLS record compression even if it is supported. This option is set by
260default. To switch it off use SSL_clear_options(). Note that TLS record
261compression is not recommended and is not available at security level 2 or
262above. From OpenSSL 3.2 the default security level is 2, so clearing this option
263will have no effect without also changing the default security level. See
264L<SSL_CTX_set_security_level(3)>.
265
266=item SSL_OP_NO_ENCRYPT_THEN_MAC
267
268Normally clients and servers will transparently attempt to negotiate the
269RFC7366 Encrypt-then-MAC option on TLS and DTLS connection.
270
271If this option is set, Encrypt-then-MAC is disabled. Clients will not
272propose, and servers will not accept the extension.
273
274=item SSL_OP_NO_EXTENDED_MASTER_SECRET
275
276Normally clients and servers will transparently attempt to negotiate the
277RFC7627 Extended Master Secret option on TLS and DTLS connection.
278
279If this option is set, Extended Master Secret is disabled. Clients will
280not propose, and servers will not accept the extension.
281
282=item SSL_OP_NO_QUERY_MTU
283
284Do not query the MTU. Only affects DTLS connections.
285
286=item SSL_OP_NO_RENEGOTIATION
287
288Disable all renegotiation in TLSv1.2 and earlier. Do not send HelloRequest
289messages, and ignore renegotiation requests via ClientHello.
290
291=item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
292
293When performing renegotiation as a server, always start a new session
294(i.e., session resumption requests are only accepted in the initial
295handshake). This option is not needed for clients.
296
297=item SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1,
298SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_3, SSL_OP_NO_DTLSv1, SSL_OP_NO_DTLSv1_2
299
300These options turn off the SSLv3, TLSv1, TLSv1.1, TLSv1.2 or TLSv1.3 protocol
301versions with TLS or the DTLSv1, DTLSv1.2 versions with DTLS,
302respectively.
303As of OpenSSL 1.1.0, these options are deprecated, use
304L<SSL_CTX_set_min_proto_version(3)> and
305L<SSL_CTX_set_max_proto_version(3)> instead.
306
307=item SSL_OP_NO_TICKET
308
309SSL/TLS supports two mechanisms for resuming sessions: session ids and stateless
310session tickets.
311
312When using session ids a copy of the session information is
313cached on the server and a unique id is sent to the client. When the client
314wishes to resume it provides the unique id so that the server can retrieve the
315session information from its cache.
316
317When using stateless session tickets the server uses a session ticket encryption
318key to encrypt the session information. This encrypted data is sent to the
319client as a "ticket". When the client wishes to resume it sends the encrypted
320data back to the server. The server uses its key to decrypt the data and resume
321the session. In this way the server can operate statelessly - no session
322information needs to be cached locally.
323
324The TLSv1.3 protocol only supports tickets and does not directly support session
325ids. However, OpenSSL allows two modes of ticket operation in TLSv1.3: stateful
326and stateless. Stateless tickets work the same way as in TLSv1.2 and below.
327Stateful tickets mimic the session id behaviour available in TLSv1.2 and below.
328The session information is cached on the server and the session id is wrapped up
329in a ticket and sent back to the client. When the client wishes to resume, it
330presents a ticket in the same way as for stateless tickets. The server can then
331extract the session id from the ticket and retrieve the session information from
332its cache.
333
334By default OpenSSL will use stateless tickets. The SSL_OP_NO_TICKET option will
335cause stateless tickets to not be issued. In TLSv1.2 and below this means no
336ticket gets sent to the client at all. In TLSv1.3 a stateful ticket will be
337sent. This is a server-side option only.
338
339In TLSv1.3 it is possible to suppress all tickets (stateful and stateless) from
340being sent by calling L<SSL_CTX_set_num_tickets(3)> or
341L<SSL_set_num_tickets(3)>.
342
343=item SSL_OP_PRIORITIZE_CHACHA
344
345When SSL_OP_CIPHER_SERVER_PREFERENCE is set, temporarily reprioritize
346ChaCha20-Poly1305 ciphers to the top of the server cipher list if a
347ChaCha20-Poly1305 cipher is at the top of the client cipher list. This helps
348those clients (e.g. mobile) use ChaCha20-Poly1305 if that cipher is anywhere
349in the server cipher list; but still allows other clients to use AES and other
350ciphers. Requires B<SSL_OP_CIPHER_SERVER_PREFERENCE>.
351
352=item SSL_OP_TLS_ROLLBACK_BUG
353
354Disable version rollback attack detection.
355
356During the client key exchange, the client must send the same information
357about acceptable SSL/TLS protocol levels as during the first hello. Some
358clients violate this rule by adapting to the server's answer. (Example:
359the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
360only understands up to SSLv3. In this case the client must still use the
361same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
362to the server's answer and violate the version rollback protection.)
363
364=back
365
366The following options no longer have any effect but their identifiers are
367retained for compatibility purposes:
368
369=over 4
370
371=item SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
372
373=item SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
374
375=item SSL_OP_SSLEAY_080_CLIENT_DH_BUG
376
377=item SSL_OP_TLS_D5_BUG
378
379=item SSL_OP_TLS_BLOCK_PADDING_BUG
380
381=item SSL_OP_MSIE_SSLV2_RSA_PADDING
382
383=item SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
384
385=item SSL_OP_MICROSOFT_SESS_ID_BUG
386
387=item SSL_OP_NETSCAPE_CHALLENGE_BUG
388
389=item SSL_OP_PKCS1_CHECK_1
390
391=item SSL_OP_PKCS1_CHECK_2
392
393=item SSL_OP_SINGLE_DH_USE
394
395=item SSL_OP_SINGLE_ECDH_USE
396
397=item SSL_OP_EPHEMERAL_RSA
398
399=item SSL_OP_NETSCAPE_CA_DN_BUG
400
401=item SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
402
403=back
404
405=head1 SECURE RENEGOTIATION
406
407OpenSSL always attempts to use secure renegotiation as
408described in RFC5746. This counters the prefix attack described in
409CVE-2009-3555 and elsewhere.
410
411This attack has far reaching consequences which application writers should be
412aware of. In the description below an implementation supporting secure
413renegotiation is referred to as I<patched>. A server not supporting secure
414renegotiation is referred to as I<unpatched>.
415
416The following sections describe the operations permitted by OpenSSL's secure
417renegotiation implementation.
418
419=head2 Patched client and server
420
421Connections and renegotiation are always permitted by OpenSSL implementations.
422
423=head2 Unpatched client and patched OpenSSL server
424
425The initial connection succeeds but client renegotiation is denied by the
426server with a B<no_renegotiation> warning alert if TLS v1.0 is used or a fatal
427B<handshake_failure> alert in SSL v3.0.
428
429If the patched OpenSSL server attempts to renegotiate a fatal
430B<handshake_failure> alert is sent. This is because the server code may be
431unaware of the unpatched nature of the client.
432
433If the option B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> is set then
434renegotiation B<always> succeeds.
435
436=head2 Patched OpenSSL client and unpatched server
437
438If the option B<SSL_OP_LEGACY_SERVER_CONNECT> or
439B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> is set then initial connections
440and renegotiation between patched OpenSSL clients and unpatched servers
441succeeds. If neither option is set then initial connections to unpatched
442servers will fail.
443
444Setting the option B<SSL_OP_LEGACY_SERVER_CONNECT> has security implications;
445clients that are willing to connect to servers that do not implement
446RFC 5746 secure renegotiation are subject to attacks such as
447CVE-2009-3555.
448
449OpenSSL client applications wishing to ensure they can connect to unpatched
450servers should always B<set> B<SSL_OP_LEGACY_SERVER_CONNECT>
451
452OpenSSL client applications that want to ensure they can B<not> connect to
453unpatched servers (and thus avoid any security issues) should always B<clear>
454B<SSL_OP_LEGACY_SERVER_CONNECT> using SSL_CTX_clear_options() or
455SSL_clear_options().
456
457The difference between the B<SSL_OP_LEGACY_SERVER_CONNECT> and
458B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> options is that
459B<SSL_OP_LEGACY_SERVER_CONNECT> enables initial connections and secure
460renegotiation between OpenSSL clients and unpatched servers B<only>, while
461B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> allows initial connections
462and renegotiation between OpenSSL and unpatched clients or servers.
463
464=head2 Applicability of options to QUIC connections and streams
465
466These options apply to SSL objects referencing a QUIC connection:
467
468=over 4
469
470=item SSL_OP_ALLOW_NO_DHE_KEX
471
472=item SSL_OP_NO_TX_CERTIFICATE_COMPRESSION
473
474=item SSL_OP_NO_RX_CERTIFICATE_COMPRESSION
475
476=item SSL_OP_NO_TICKET
477
478=item SSL_OP_PRIORITIZE_CHACHA
479
480=back
481
482These options apply to SSL objects referencing a QUIC stream:
483
484=over 4
485
486=item SSL_OP_CLEANSE_PLAINTEXT
487
488=back
489
490Options on QUIC connections are initialized from the options set on SSL_CTX
491before a QUIC connection SSL object is created. Options on QUIC streams are
492initialised from the options configured on the QUIC connection SSL object
493they are created from.
494
495Setting options which relate to QUIC streams on a QUIC connection SSL object has
496no direct effect on the QUIC connection SSL object itself, but will change the
497options set on the default stream (if there is one) and will also determine the
498default options set on any future streams which are created.
499
500Other options not mentioned above do not have an effect and will be ignored.
501
502Options which relate to QUIC streams may also be set directly on QUIC stream SSL
503objects. Setting connection-related options on such an object has no effect.
504
505=head1 RETURN VALUES
506
507SSL_CTX_set_options() and SSL_set_options() return the new options bit-mask
508after adding B<options>.
509
510SSL_CTX_clear_options() and SSL_clear_options() return the new options bit-mask
511after clearing B<options>.
512
513SSL_CTX_get_options() and SSL_get_options() return the current bit-mask.
514
515SSL_get_secure_renegotiation_support() returns 1 is the peer supports
516secure renegotiation and 0 if it does not.
517
518=head1 SEE ALSO
519
520L<ssl(7)>, L<SSL_new(3)>, L<SSL_clear(3)>, L<SSL_shutdown(3)>
521L<SSL_CTX_set_tmp_dh_callback(3)>,
522L<SSL_CTX_set_min_proto_version(3)>,
523L<openssl-dhparam(1)>
524
525=head1 HISTORY
526
527The attempt to always try to use secure renegotiation was added in
528OpenSSL 0.9.8m.
529
530The B<SSL_OP_PRIORITIZE_CHACHA> and B<SSL_OP_NO_RENEGOTIATION> options
531were added in OpenSSL 1.1.1.
532
533The B<SSL_OP_NO_EXTENDED_MASTER_SECRET> and B<SSL_OP_IGNORE_UNEXPECTED_EOF>
534options were added in OpenSSL 3.0.
535
536The B<SSL_OP_> constants and the corresponding parameter and return values
537of the affected functions were changed to C<uint64_t> type in OpenSSL 3.0.
538For that reason it is no longer possible use the B<SSL_OP_> macro values
539in preprocessor C<#if> conditions. However it is still possible to test
540whether these macros are defined or not.
541
542=head1 COPYRIGHT
543
544Copyright 2001-2023 The OpenSSL Project Authors. All Rights Reserved.
545
546Licensed under the Apache License 2.0 (the "License"). You may not use
547this file except in compliance with the License. You can obtain a copy
548in the file LICENSE in the source distribution or at
549L<https://www.openssl.org/source/license.html>.
550
551=cut
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette