SSL_CTX_set_options.pod 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_options, SSL_set_options, SSL_CTX_clear_options,
  4. SSL_clear_options, SSL_CTX_get_options, SSL_get_options,
  5. SSL_get_secure_renegotiation_support - manipulate SSL options
  6. =head1 SYNOPSIS
  7. #include <openssl/ssl.h>
  8. long SSL_CTX_set_options(SSL_CTX *ctx, long options);
  9. long SSL_set_options(SSL *ssl, long options);
  10. long SSL_CTX_clear_options(SSL_CTX *ctx, long options);
  11. long SSL_clear_options(SSL *ssl, long options);
  12. long SSL_CTX_get_options(SSL_CTX *ctx);
  13. long SSL_get_options(SSL *ssl);
  14. long SSL_get_secure_renegotiation_support(SSL *ssl);
  15. =head1 DESCRIPTION
  16. SSL_CTX_set_options() adds the options set via bitmask in B<options> to B<ctx>.
  17. Options already set before are not cleared!
  18. SSL_set_options() adds the options set via bitmask in B<options> to B<ssl>.
  19. Options already set before are not cleared!
  20. SSL_CTX_clear_options() clears the options set via bitmask in B<options>
  21. to B<ctx>.
  22. SSL_clear_options() clears the options set via bitmask in B<options> to B<ssl>.
  23. SSL_CTX_get_options() returns the options set for B<ctx>.
  24. SSL_get_options() returns the options set for B<ssl>.
  25. SSL_get_secure_renegotiation_support() indicates whether the peer supports
  26. secure renegotiation.
  27. Note, this is implemented via a macro.
  28. =head1 NOTES
  29. The behaviour of the SSL library can be changed by setting several options.
  30. The options are coded as bitmasks and can be combined by a bitwise B<or>
  31. operation (|).
  32. SSL_CTX_set_options() and SSL_set_options() affect the (external)
  33. protocol behaviour of the SSL library. The (internal) behaviour of
  34. the API can be changed by using the similar
  35. L<SSL_CTX_set_mode(3)> and SSL_set_mode() functions.
  36. During a handshake, the option settings of the SSL object are used. When
  37. a new SSL object is created from a context using SSL_new(), the current
  38. option setting is copied. Changes to B<ctx> do not affect already created
  39. SSL objects. SSL_clear() does not affect the settings.
  40. The following B<bug workaround> options are available:
  41. =over 4
  42. =item SSL_OP_SAFARI_ECDHE_ECDSA_BUG
  43. Don't prefer ECDHE-ECDSA ciphers when the client appears to be Safari on OS X.
  44. OS X 10.8..10.8.3 has broken support for ECDHE-ECDSA ciphers.
  45. =item SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
  46. Disables a countermeasure against a SSL 3.0/TLS 1.0 protocol
  47. vulnerability affecting CBC ciphers, which cannot be handled by some
  48. broken SSL implementations. This option has no effect for connections
  49. using other ciphers.
  50. =item SSL_OP_TLSEXT_PADDING
  51. Adds a padding extension to ensure the ClientHello size is never between
  52. 256 and 511 bytes in length. This is needed as a workaround for some
  53. implementations.
  54. =item SSL_OP_ALL
  55. All of the above bug workarounds plus B<SSL_OP_LEGACY_SERVER_CONNECT> as
  56. mentioned below.
  57. =back
  58. It is usually safe to use B<SSL_OP_ALL> to enable the bug workaround
  59. options if compatibility with somewhat broken implementations is
  60. desired.
  61. The following B<modifying> options are available:
  62. =over 4
  63. =item SSL_OP_TLS_ROLLBACK_BUG
  64. Disable version rollback attack detection.
  65. During the client key exchange, the client must send the same information
  66. about acceptable SSL/TLS protocol levels as during the first hello. Some
  67. clients violate this rule by adapting to the server's answer. (Example:
  68. the client sends a SSLv2 hello and accepts up to SSLv3.1=TLSv1, the server
  69. only understands up to SSLv3. In this case the client must still use the
  70. same SSLv3.1=TLSv1 announcement. Some clients step down to SSLv3 with respect
  71. to the server's answer and violate the version rollback protection.)
  72. =item SSL_OP_CIPHER_SERVER_PREFERENCE
  73. When choosing a cipher, use the server's preferences instead of the client
  74. preferences. When not set, the SSL server will always follow the clients
  75. preferences. When set, the SSL/TLS server will choose following its
  76. own preferences.
  77. =item SSL_OP_NO_SSLv3, SSL_OP_NO_TLSv1, SSL_OP_NO_TLSv1_1,
  78. SSL_OP_NO_TLSv1_2, SSL_OP_NO_TLSv1_3, SSL_OP_NO_DTLSv1, SSL_OP_NO_DTLSv1_2
  79. These options turn off the SSLv3, TLSv1, TLSv1.1, TLSv1.2 or TLSv1.3 protocol
  80. versions with TLS or the DTLSv1, DTLSv1.2 versions with DTLS,
  81. respectively.
  82. As of OpenSSL 1.1.0, these options are deprecated, use
  83. L<SSL_CTX_set_min_proto_version(3)> and
  84. L<SSL_CTX_set_max_proto_version(3)> instead.
  85. =item SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
  86. When performing renegotiation as a server, always start a new session
  87. (i.e., session resumption requests are only accepted in the initial
  88. handshake). This option is not needed for clients.
  89. =item SSL_OP_NO_COMPRESSION
  90. Do not use compression even if it is supported.
  91. =item SSL_OP_NO_QUERY_MTU
  92. Do not query the MTU. Only affects DTLS connections.
  93. =item SSL_OP_COOKIE_EXCHANGE
  94. Turn on Cookie Exchange as described in RFC4347 Section 4.2.1. Only affects
  95. DTLS connections.
  96. =item SSL_OP_NO_TICKET
  97. Normally clients and servers will, where possible, transparently make use
  98. of RFC4507bis tickets for stateless session resumption.
  99. If this option is set this functionality is disabled and tickets will
  100. not be used by clients or servers.
  101. This option only applies to TLSv1.2 and below. It is ignored for TLSv1.3.
  102. =item SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
  103. Allow legacy insecure renegotiation between OpenSSL and unpatched clients or
  104. servers. See the B<SECURE RENEGOTIATION> section for more details.
  105. =item SSL_OP_LEGACY_SERVER_CONNECT
  106. Allow legacy insecure renegotiation between OpenSSL and unpatched servers
  107. B<only>: this option is currently set by default. See the
  108. B<SECURE RENEGOTIATION> section for more details.
  109. =item SSL_OP_NO_ENCRYPT_THEN_MAC
  110. Normally clients and servers will transparently attempt to negotiate the
  111. RFC7366 Encrypt-then-MAC option on TLS and DTLS connection.
  112. If this option is set, Encrypt-then-MAC is disabled. Clients will not
  113. propose, and servers will not accept the extension.
  114. =item SSL_OP_NO_RENEGOTIATION
  115. Disable all renegotiation in TLSv1.2 and earlier. Do not send HelloRequest
  116. messages, and ignore renegotiation requests via ClientHello.
  117. =item SSL_OP_ALLOW_NO_DHE_KEX
  118. In TLSv1.3 allow a non-(ec)dhe based key exchange mode on resumption. This means
  119. that there will be no forward secrecy for the resumed session.
  120. =item SSL_OP_PRIORITIZE_CHACHA
  121. When SSL_OP_CIPHER_SERVER_PREFERENCE is set, temporarily reprioritize
  122. ChaCha20-Poly1305 ciphers to the top of the server cipher list if a
  123. ChaCha20-Poly1305 cipher is at the top of the client cipher list. This helps
  124. those clients (e.g. mobile) use ChaCha20-Poly1305 if that cipher is anywhere
  125. in the server cipher list; but still allows other clients to use AES and other
  126. ciphers. Requires B<SSL_OP_CIPHER_SERVER_PREFERENCE>.
  127. =item SSL_OP_ENABLE_MIDDLEBOX_COMPAT
  128. If set then dummy Change Cipher Spec (CCS) messages are sent in TLSv1.3. This
  129. has the effect of making TLSv1.3 look more like TLSv1.2 so that middleboxes that
  130. do not understand TLSv1.3 will not drop the connection. Regardless of whether
  131. this option is set or not CCS messages received from the peer will always be
  132. ignored in TLSv1.3. This option is set by default. To switch it off use
  133. SSL_clear_options(). A future version of OpenSSL may not set this by default.
  134. =back
  135. The following options no longer have any effect but their identifiers are
  136. retained for compatibility purposes:
  137. =over 4
  138. =item SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
  139. =item SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
  140. =item SSL_OP_SSLEAY_080_CLIENT_DH_BUG
  141. =item SSL_OP_TLS_D5_BUG
  142. =item SSL_OP_TLS_BLOCK_PADDING_BUG
  143. =item SSL_OP_MSIE_SSLV2_RSA_PADDING
  144. =item SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
  145. =item SSL_OP_MICROSOFT_SESS_ID_BUG
  146. =item SSL_OP_NETSCAPE_CHALLENGE_BUG
  147. =item SSL_OP_PKCS1_CHECK_1
  148. =item SSL_OP_PKCS1_CHECK_2
  149. =item SSL_OP_SINGLE_DH_USE
  150. =item SSL_OP_SINGLE_ECDH_USE
  151. =item SSL_OP_EPHEMERAL_RSA
  152. =back
  153. =head1 SECURE RENEGOTIATION
  154. OpenSSL always attempts to use secure renegotiation as
  155. described in RFC5746. This counters the prefix attack described in
  156. CVE-2009-3555 and elsewhere.
  157. This attack has far reaching consequences which application writers should be
  158. aware of. In the description below an implementation supporting secure
  159. renegotiation is referred to as I<patched>. A server not supporting secure
  160. renegotiation is referred to as I<unpatched>.
  161. The following sections describe the operations permitted by OpenSSL's secure
  162. renegotiation implementation.
  163. =head2 Patched client and server
  164. Connections and renegotiation are always permitted by OpenSSL implementations.
  165. =head2 Unpatched client and patched OpenSSL server
  166. The initial connection succeeds but client renegotiation is denied by the
  167. server with a B<no_renegotiation> warning alert if TLS v1.0 is used or a fatal
  168. B<handshake_failure> alert in SSL v3.0.
  169. If the patched OpenSSL server attempts to renegotiate a fatal
  170. B<handshake_failure> alert is sent. This is because the server code may be
  171. unaware of the unpatched nature of the client.
  172. If the option B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> is set then
  173. renegotiation B<always> succeeds.
  174. =head2 Patched OpenSSL client and unpatched server.
  175. If the option B<SSL_OP_LEGACY_SERVER_CONNECT> or
  176. B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> is set then initial connections
  177. and renegotiation between patched OpenSSL clients and unpatched servers
  178. succeeds. If neither option is set then initial connections to unpatched
  179. servers will fail.
  180. The option B<SSL_OP_LEGACY_SERVER_CONNECT> is currently set by default even
  181. though it has security implications: otherwise it would be impossible to
  182. connect to unpatched servers (i.e. all of them initially) and this is clearly
  183. not acceptable. Renegotiation is permitted because this does not add any
  184. additional security issues: during an attack clients do not see any
  185. renegotiations anyway.
  186. As more servers become patched the option B<SSL_OP_LEGACY_SERVER_CONNECT> will
  187. B<not> be set by default in a future version of OpenSSL.
  188. OpenSSL client applications wishing to ensure they can connect to unpatched
  189. servers should always B<set> B<SSL_OP_LEGACY_SERVER_CONNECT>
  190. OpenSSL client applications that want to ensure they can B<not> connect to
  191. unpatched servers (and thus avoid any security issues) should always B<clear>
  192. B<SSL_OP_LEGACY_SERVER_CONNECT> using SSL_CTX_clear_options() or
  193. SSL_clear_options().
  194. The difference between the B<SSL_OP_LEGACY_SERVER_CONNECT> and
  195. B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> options is that
  196. B<SSL_OP_LEGACY_SERVER_CONNECT> enables initial connections and secure
  197. renegotiation between OpenSSL clients and unpatched servers B<only>, while
  198. B<SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION> allows initial connections
  199. and renegotiation between OpenSSL and unpatched clients or servers.
  200. =head1 RETURN VALUES
  201. SSL_CTX_set_options() and SSL_set_options() return the new options bitmask
  202. after adding B<options>.
  203. SSL_CTX_clear_options() and SSL_clear_options() return the new options bitmask
  204. after clearing B<options>.
  205. SSL_CTX_get_options() and SSL_get_options() return the current bitmask.
  206. SSL_get_secure_renegotiation_support() returns 1 is the peer supports
  207. secure renegotiation and 0 if it does not.
  208. =head1 SEE ALSO
  209. L<ssl(7)>, L<SSL_new(3)>, L<SSL_clear(3)>,
  210. L<SSL_CTX_set_tmp_dh_callback(3)>,
  211. L<SSL_CTX_set_min_proto_version(3)>,
  212. L<dhparam(1)>
  213. =head1 HISTORY
  214. The attempt to always try to use secure renegotiation was added in
  215. Openssl 0.9.8m.
  216. B<SSL_OP_PRIORITIZE_CHACHA> and B<SSL_OP_NO_RENEGOTIATION> were added in
  217. OpenSSL 1.1.1.
  218. =head1 COPYRIGHT
  219. Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
  220. Licensed under the OpenSSL license (the "License"). You may not use
  221. this file except in compliance with the License. You can obtain a copy
  222. in the file LICENSE in the source distribution or at
  223. L<https://www.openssl.org/source/license.html>.
  224. =cut