SSL_CTX_set_mode.pod 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_mode, SSL_CTX_clear_mode, SSL_set_mode, SSL_clear_mode, SSL_CTX_get_mode, SSL_get_mode - manipulate SSL engine mode
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. long SSL_CTX_set_mode(SSL_CTX *ctx, long mode);
  7. long SSL_CTX_clear_mode(SSL_CTX *ctx, long mode);
  8. long SSL_set_mode(SSL *ssl, long mode);
  9. long SSL_clear_mode(SSL *ssl, long mode);
  10. long SSL_CTX_get_mode(SSL_CTX *ctx);
  11. long SSL_get_mode(SSL *ssl);
  12. =head1 DESCRIPTION
  13. SSL_CTX_set_mode() adds the mode set via bitmask in B<mode> to B<ctx>.
  14. Options already set before are not cleared.
  15. SSL_CTX_clear_mode() removes the mode set via bitmask in B<mode> from B<ctx>.
  16. SSL_set_mode() adds the mode set via bitmask in B<mode> to B<ssl>.
  17. Options already set before are not cleared.
  18. SSL_clear_mode() removes the mode set via bitmask in B<mode> from B<ssl>.
  19. SSL_CTX_get_mode() returns the mode set for B<ctx>.
  20. SSL_get_mode() returns the mode set for B<ssl>.
  21. =head1 NOTES
  22. The following mode changes are available:
  23. =over 4
  24. =item SSL_MODE_ENABLE_PARTIAL_WRITE
  25. Allow SSL_write_ex(..., n, &r) to return with 0 < r < n (i.e. report success
  26. when just a single record has been written). This works in a similar way for
  27. SSL_write(). When not set (the default), SSL_write_ex() or SSL_write() will only
  28. report success once the complete chunk was written. Once SSL_write_ex() or
  29. SSL_write() returns successful, B<r> bytes have been written and the next call
  30. to SSL_write_ex() or SSL_write() must only send the n-r bytes left, imitating
  31. the behaviour of write().
  32. =item SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
  33. Make it possible to retry SSL_write_ex() or SSL_write() with changed buffer
  34. location (the buffer contents must stay the same). This is not the default to
  35. avoid the misconception that non-blocking SSL_write() behaves like
  36. non-blocking write().
  37. =item SSL_MODE_AUTO_RETRY
  38. During normal operations, non-application data records might need to be sent or
  39. received that the application is not aware of.
  40. If a non-application data record was processed,
  41. L<SSL_read_ex(3)> and L<SSL_read(3)> can return with a failure and indicate the
  42. need to retry with B<SSL_ERROR_WANT_READ>.
  43. If such a non-application data record was processed, the flag
  44. B<SSL_MODE_AUTO_RETRY> causes it to try to process the next record instead of
  45. returning.
  46. In a non-blocking environment applications must be prepared to handle
  47. incomplete read/write operations.
  48. Setting B<SSL_MODE_AUTO_RETRY> for a non-blocking B<BIO> will process
  49. non-application data records until either no more data is available or
  50. an application data record has been processed.
  51. In a blocking environment, applications are not always prepared to
  52. deal with the functions returning intermediate reports such as retry
  53. requests, and setting the B<SSL_MODE_AUTO_RETRY> flag will cause the functions
  54. to only return after successfully processing an application data record or a
  55. failure.
  56. Turning off B<SSL_MODE_AUTO_RETRY> can be useful with blocking B<BIO>s in case
  57. they are used in combination with something like select() or poll().
  58. Otherwise the call to SSL_read() or SSL_read_ex() might hang when a
  59. non-application record was sent and no application data was sent.
  60. =item SSL_MODE_RELEASE_BUFFERS
  61. When we no longer need a read buffer or a write buffer for a given SSL,
  62. then release the memory we were using to hold it.
  63. Using this flag can
  64. save around 34k per idle SSL connection.
  65. This flag has no effect on SSL v2 connections, or on DTLS connections.
  66. =item SSL_MODE_SEND_FALLBACK_SCSV
  67. Send TLS_FALLBACK_SCSV in the ClientHello.
  68. To be set only by applications that reconnect with a downgraded protocol
  69. version; see draft-ietf-tls-downgrade-scsv-00 for details.
  70. DO NOT ENABLE THIS if your application attempts a normal handshake.
  71. Only use this in explicit fallback retries, following the guidance
  72. in draft-ietf-tls-downgrade-scsv-00.
  73. =item SSL_MODE_ASYNC
  74. Enable asynchronous processing. TLS I/O operations may indicate a retry with
  75. SSL_ERROR_WANT_ASYNC with this mode set if an asynchronous capable engine is
  76. used to perform cryptographic operations. See L<SSL_get_error(3)>.
  77. =item SSL_MODE_NO_KTLS_TX
  78. Disable the use of the kernel TLS egress data-path.
  79. By default kernel TLS is enabled if it is supported by the negotiated ciphersuites
  80. and extensions and OpenSSL has been compiled with support for it.
  81. The kernel TLS data-path implements the record layer,
  82. and the crypto algorithm. The kernel will utilize the best hardware
  83. available for crypto. Using the kernel data-path should reduce the memory
  84. footprint of OpenSSL because no buffering is required. Also, the throughput
  85. should improve because data copy is avoided when user data is encrypted into
  86. kernel memory instead of the usual encrypt than copy to kernel.
  87. Kernel TLS might not support all the features of OpenSSL. For instance,
  88. renegotiation, and setting the maximum fragment size is not possible as of
  89. Linux 4.20.
  90. =back
  91. All modes are off by default except for SSL_MODE_AUTO_RETRY which is on by
  92. default since 1.1.1.
  93. =head1 RETURN VALUES
  94. SSL_CTX_set_mode() and SSL_set_mode() return the new mode bitmask
  95. after adding B<mode>.
  96. SSL_CTX_get_mode() and SSL_get_mode() return the current bitmask.
  97. =head1 SEE ALSO
  98. L<ssl(7)>, L<SSL_read_ex(3)>, L<SSL_read(3)>, L<SSL_write_ex(3)> or
  99. L<SSL_write(3)>, L<SSL_get_error(3)>
  100. =head1 HISTORY
  101. SSL_MODE_ASYNC was added in OpenSSL 1.1.0.
  102. SSL_MODE_NO_KTLS_TX was added in OpenSSL 3.0.0.
  103. =head1 COPYRIGHT
  104. Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
  105. Licensed under the Apache License 2.0 (the "License"). You may not use
  106. this file except in compliance with the License. You can obtain a copy
  107. in the file LICENSE in the source distribution or at
  108. L<https://www.openssl.org/source/license.html>.
  109. =cut