Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 1 | =pod |
| 2 | |
| 3 | =head1 NAME |
| 4 | |
| 5 | SSL_CTX_set_mode, SSL_set_mode, SSL_CTX_get_mode, SSL_get_mode - manipulate SSL engine mode |
| 6 | |
| 7 | =head1 SYNOPSIS |
| 8 | |
| 9 | #include <openssl/ssl.h> |
| 10 | |
| 11 | long SSL_CTX_set_mode(SSL_CTX *ctx, long mode); |
| 12 | long SSL_set_mode(SSL *ssl, long mode); |
| 13 | |
| 14 | long SSL_CTX_get_mode(SSL_CTX *ctx); |
| 15 | long SSL_get_mode(SSL *ssl); |
| 16 | |
| 17 | =head1 DESCRIPTION |
| 18 | |
| 19 | SSL_CTX_set_mode() adds the mode set via bitmask in B<mode> to B<ctx>. |
| 20 | Options already set before are not cleared. |
| 21 | |
| 22 | SSL_set_mode() adds the mode set via bitmask in B<mode> to B<ssl>. |
| 23 | Options already set before are not cleared. |
| 24 | |
| 25 | SSL_CTX_get_mode() returns the mode set for B<ctx>. |
| 26 | |
| 27 | SSL_get_mode() returns the mode set for B<ssl>. |
| 28 | |
| 29 | =head1 NOTES |
| 30 | |
| 31 | The following mode changes are available: |
| 32 | |
| 33 | =over 4 |
| 34 | |
| 35 | =item SSL_MODE_ENABLE_PARTIAL_WRITE |
| 36 | |
Matt Caswell | 7714dc5 | 2016-10-20 15:04:21 +0100 | [diff] [blame] | 37 | Allow SSL_write_ex(..., n, &r) to return with 0 < r < n (i.e. report success |
| 38 | when just a single record has been written). This works in a similar way for |
| 39 | SSL_write(). When not set (the default), SSL_write_ex() or SSL_write() will only |
| 40 | report success once the complete chunk was written. Once SSL_write_ex() or |
Matt Caswell | 6782e5f | 2016-10-21 16:16:20 +0100 | [diff] [blame] | 41 | SSL_write() returns successful, B<r> bytes have been written and the next call |
| 42 | to SSL_write_ex() or SSL_write() must only send the n-r bytes left, imitating |
| 43 | the behaviour of write(). |
Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 44 | |
| 45 | =item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
| 46 | |
Matt Caswell | 7714dc5 | 2016-10-20 15:04:21 +0100 | [diff] [blame] | 47 | Make it possible to retry SSL_write_ex() or SSL_write() with changed buffer |
| 48 | location (the buffer contents must stay the same). This is not the default to |
| 49 | avoid the misconception that non-blocking SSL_write() behaves like |
Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 50 | non-blocking write(). |
| 51 | |
| 52 | =item SSL_MODE_AUTO_RETRY |
| 53 | |
| 54 | Never bother the application with retries if the transport is blocking. |
| 55 | If a renegotiation take place during normal operation, a |
Matt Caswell | 7714dc5 | 2016-10-20 15:04:21 +0100 | [diff] [blame] | 56 | L<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_write_ex(3)> or L<SSL_write(3)> would |
| 57 | return with a failure and indicate the need to retry with SSL_ERROR_WANT_READ. |
Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 58 | In a non-blocking environment applications must be prepared to handle |
| 59 | incomplete read/write operations. |
| 60 | In a blocking environment, applications are not always prepared to |
| 61 | deal with read/write operations returning without success report. The |
| 62 | flag SSL_MODE_AUTO_RETRY will cause read/write operations to only |
| 63 | return after the handshake and successful completion. |
| 64 | |
Ben Laurie | 8671b89 | 2008-06-03 02:48:34 +0000 | [diff] [blame] | 65 | =item SSL_MODE_RELEASE_BUFFERS |
| 66 | |
| 67 | When we no longer need a read buffer or a write buffer for a given SSL, |
Rich Salz | 63c574f | 2015-01-27 16:43:53 -0500 | [diff] [blame] | 68 | then release the memory we were using to hold it. |
| 69 | Using this flag can |
Ben Laurie | 8671b89 | 2008-06-03 02:48:34 +0000 | [diff] [blame] | 70 | save around 34k per idle SSL connection. |
| 71 | This flag has no effect on SSL v2 connections, or on DTLS connections. |
| 72 | |
Bodo Moeller | 98f1ac7 | 2014-10-21 22:43:08 +0200 | [diff] [blame] | 73 | =item SSL_MODE_SEND_FALLBACK_SCSV |
Bodo Moeller | fb0e87f | 2014-10-15 10:43:50 +0200 | [diff] [blame] | 74 | |
| 75 | Send TLS_FALLBACK_SCSV in the ClientHello. |
Bodo Moeller | 98f1ac7 | 2014-10-21 22:43:08 +0200 | [diff] [blame] | 76 | To be set only by applications that reconnect with a downgraded protocol |
Bodo Moeller | fb0e87f | 2014-10-15 10:43:50 +0200 | [diff] [blame] | 77 | version; see draft-ietf-tls-downgrade-scsv-00 for details. |
| 78 | |
Bodo Moeller | 98f1ac7 | 2014-10-21 22:43:08 +0200 | [diff] [blame] | 79 | DO NOT ENABLE THIS if your application attempts a normal handshake. |
| 80 | Only use this in explicit fallback retries, following the guidance |
| 81 | in draft-ietf-tls-downgrade-scsv-00. |
| 82 | |
Matt Caswell | bc8857b | 2015-10-06 13:48:43 +0100 | [diff] [blame] | 83 | =item SSL_MODE_ASYNC |
| 84 | |
| 85 | Enable asynchronous processing. TLS I/O operations may indicate a retry with |
| 86 | SSL_ERROR_WANT_ASYNC with this mode set if an asynchronous capable engine is |
| 87 | used to perform cryptographic operations. See L<SSL_get_error(3)>. |
| 88 | |
Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 89 | =back |
| 90 | |
| 91 | =head1 RETURN VALUES |
| 92 | |
| 93 | SSL_CTX_set_mode() and SSL_set_mode() return the new mode bitmask |
| 94 | after adding B<mode>. |
| 95 | |
| 96 | SSL_CTX_get_mode() and SSL_get_mode() return the current bitmask. |
| 97 | |
| 98 | =head1 SEE ALSO |
| 99 | |
Richard Levitte | b97fdb5 | 2016-11-11 09:33:09 +0100 | [diff] [blame] | 100 | L<ssl(7)>, L<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_write_ex(3)> or |
Matt Caswell | 7714dc5 | 2016-10-20 15:04:21 +0100 | [diff] [blame] | 101 | L<SSL_write(3)>, L<SSL_get_error(3)> |
Matt Caswell | bc8857b | 2015-10-06 13:48:43 +0100 | [diff] [blame] | 102 | |
Matt Caswell | bc8857b | 2015-10-06 13:48:43 +0100 | [diff] [blame] | 103 | =head1 HISTORY |
| 104 | |
| 105 | SSL_MODE_ASYNC was first added to OpenSSL 1.1.0. |
Lutz Jänicke | f282ca7 | 2001-02-13 11:43:11 +0000 | [diff] [blame] | 106 | |
Rich Salz | e2f9261 | 2016-05-18 11:44:05 -0400 | [diff] [blame] | 107 | =head1 COPYRIGHT |
| 108 | |
| 109 | Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. |
| 110 | |
| 111 | Licensed under the OpenSSL license (the "License"). You may not use |
| 112 | this file except in compliance with the License. You can obtain a copy |
| 113 | in the file LICENSE in the source distribution or at |
| 114 | L<https://www.openssl.org/source/license.html>. |
| 115 | |
| 116 | =cut |