SSL_CTX_set_ct_validation_callback.pod 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. =pod
  2. =head1 NAME
  3. ssl_ct_validation_cb,
  4. SSL_enable_ct, SSL_CTX_enable_ct, SSL_disable_ct, SSL_CTX_disable_ct,
  5. SSL_set_ct_validation_callback, SSL_CTX_set_ct_validation_callback,
  6. SSL_ct_is_enabled, SSL_CTX_ct_is_enabled -
  7. control Certificate Transparency policy
  8. =head1 SYNOPSIS
  9. #include <openssl/ssl.h>
  10. typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx,
  11. const STACK_OF(SCT) *scts, void *arg);
  12. int SSL_enable_ct(SSL *s, int validation_mode);
  13. int SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode);
  14. int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback,
  15. void *arg);
  16. int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx,
  17. ssl_ct_validation_cb callback,
  18. void *arg);
  19. void SSL_disable_ct(SSL *s);
  20. void SSL_CTX_disable_ct(SSL_CTX *ctx);
  21. int SSL_ct_is_enabled(const SSL *s);
  22. int SSL_CTX_ct_is_enabled(const SSL_CTX *ctx);
  23. =head1 DESCRIPTION
  24. SSL_enable_ct() and SSL_CTX_enable_ct() enable the processing of signed
  25. certificate timestamps (SCTs) either for a given SSL connection or for all
  26. connections that share the given SSL context, respectively.
  27. This is accomplished by setting a built-in CT validation callback.
  28. The behaviour of the callback is determined by the B<validation_mode> argument,
  29. which can be either of B<SSL_CT_VALIDATION_PERMISSIVE> or
  30. B<SSL_CT_VALIDATION_STRICT> as described below.
  31. If B<validation_mode> is equal to B<SSL_CT_VALIDATION_STRICT>, then in a full
  32. TLS handshake with the verification mode set to B<SSL_VERIFY_PEER>, if the peer
  33. presents no valid SCTs the handshake will be aborted.
  34. If the verification mode is B<SSL_VERIFY_NONE>, the handshake will continue
  35. despite lack of valid SCTs.
  36. However, in that case if the verification status before the built-in callback
  37. was B<X509_V_OK> it will be set to B<X509_V_ERR_NO_VALID_SCTS> after the
  38. callback.
  39. Applications can call L<SSL_get_verify_result(3)> to check the status at
  40. handshake completion, even after session resumption since the verification
  41. status is part of the saved session state.
  42. See L<SSL_set_verify(3)>, <SSL_get_verify_result(3)>, L<SSL_session_reused(3)>.
  43. If B<validation_mode> is equal to B<SSL_CT_VALIDATION_PERMISSIVE>, then the
  44. handshake continues, and the verification status is not modified, regardless of
  45. the validation status of any SCTs.
  46. The application can still inspect the validation status of the SCTs at
  47. handshake completion.
  48. Note that with session resumption there will not be any SCTs presented during
  49. the handshake.
  50. Therefore, in applications that delay SCT policy enforcement until after
  51. handshake completion, such delayed SCT checks should only be performed when the
  52. session is not resumed.
  53. SSL_set_ct_validation_callback() and SSL_CTX_set_ct_validation_callback()
  54. register a custom callback that may implement a different policy than either of
  55. the above.
  56. This callback can examine the peer's SCTs and determine whether they are
  57. sufficient to allow the connection to continue.
  58. The TLS handshake is aborted if the verification mode is not B<SSL_VERIFY_NONE>
  59. and the callback returns a non-positive result.
  60. An arbitrary callback data argument, B<arg>, can be passed in when setting
  61. the callback.
  62. This will be passed to the callback whenever it is invoked.
  63. Ownership of this context remains with the caller.
  64. If no callback is set, SCTs will not be requested and Certificate Transparency
  65. validation will not occur.
  66. No callback will be invoked when the peer presents no certificate, e.g. by
  67. employing an anonymous (aNULL) cipher suite.
  68. In that case the handshake continues as it would had no callback been
  69. requested.
  70. Callbacks are also not invoked when the peer certificate chain is invalid or
  71. validated via DANE-TA(2) or DANE-EE(3) TLSA records which use a private X.509
  72. PKI, or no X.509 PKI at all, respectively.
  73. Clients that require SCTs are expected to not have enabled any aNULL ciphers
  74. nor to have specified server verification via DANE-TA(2) or DANE-EE(3) TLSA
  75. records.
  76. SSL_disable_ct() and SSL_CTX_disable_ct() turn off CT processing, whether
  77. enabled via the built-in or the custom callbacks, by setting a NULL callback.
  78. These may be implemented as macros.
  79. SSL_ct_is_enabled() and SSL_CTX_ct_is_enabled() return 1 if CT processing is
  80. enabled via either SSL_enable_ct() or a non-null custom callback, and 0
  81. otherwise.
  82. =head1 NOTES
  83. When SCT processing is enabled, OCSP stapling will be enabled. This is because
  84. one possible source of SCTs is the OCSP response from a server.
  85. The time returned by SSL_SESSION_get_time() will be used to evaluate whether any
  86. presented SCTs have timestamps that are in the future (and therefore invalid).
  87. =head1 RESTRICTIONS
  88. Certificate Transparency validation cannot be enabled and so a callback cannot
  89. be set if a custom client extension handler has been registered to handle SCT
  90. extensions (B<TLSEXT_TYPE_signed_certificate_timestamp>).
  91. =head1 RETURN VALUES
  92. SSL_enable_ct(), SSL_CTX_enable_ct(), SSL_CTX_set_ct_validation_callback() and
  93. SSL_set_ct_validation_callback() return 1 if the B<callback> is successfully
  94. set.
  95. They return 0 if an error occurs, e.g. a custom client extension handler has
  96. been setup to handle SCTs.
  97. SSL_disable_ct() and SSL_CTX_disable_ct() do not return a result.
  98. SSL_CTX_ct_is_enabled() and SSL_ct_is_enabled() return a 1 if a non-null CT
  99. validation callback is set, or 0 if no callback (or equivalently a NULL
  100. callback) is set.
  101. =head1 SEE ALSO
  102. L<ssl(7)>,
  103. <SSL_get_verify_result(3)>,
  104. L<SSL_session_reused(3)>,
  105. L<SSL_set_verify(3)>,
  106. L<SSL_CTX_set_verify(3)>,
  107. L<SSL_SESSION_get_time(3)>
  108. =head1 COPYRIGHT
  109. Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  110. Licensed under the Apache License 2.0 (the "License"). You may not use
  111. this file except in compliance with the License. You can obtain a copy
  112. in the file LICENSE in the source distribution or at
  113. L<https://www.openssl.org/source/license.html>.
  114. =cut