cert_verify_result.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef NET_CERT_CERT_VERIFY_RESULT_H_
  5. #define NET_CERT_CERT_VERIFY_RESULT_H_
  6. #include "base/memory/ref_counted.h"
  7. #include "base/supports_user_data.h"
  8. #include "net/base/hash_value.h"
  9. #include "net/base/net_export.h"
  10. #include "net/cert/cert_status_flags.h"
  11. #include "net/cert/ct_policy_status.h"
  12. #include "net/cert/ocsp_verify_result.h"
  13. #include "net/cert/signed_certificate_timestamp_and_status.h"
  14. namespace base {
  15. class Value;
  16. }
  17. namespace ct {
  18. enum class CTPolicyCompliance;
  19. } // namespace ct
  20. namespace net {
  21. class X509Certificate;
  22. // The result of certificate verification.
  23. //
  24. // Additional debugging or purely informational data may be added through
  25. // SupportsUserData, but such data must not be used for anything that changes
  26. // how the results are interpreted or acted upon: any data that changes the
  27. // meaning of the result must be added as a member in this class, not through
  28. // SupportsUserData.
  29. // Any Data added through SupportsUserData must implement Clone().
  30. class NET_EXPORT CertVerifyResult : public base::SupportsUserData {
  31. public:
  32. CertVerifyResult();
  33. CertVerifyResult(const CertVerifyResult& other);
  34. ~CertVerifyResult() override;
  35. CertVerifyResult& operator=(const CertVerifyResult& other);
  36. void Reset();
  37. // Creates NetLog parameter to describe the CertVerifyResult. |net_error| is
  38. // a net error code to include in the params, if non-zero. It must not be
  39. // ERR_IO_PENDING, as that is not a true error.
  40. base::Value NetLogParams(int net_error) const;
  41. // The certificate chain that was constructed during verification.
  42. //
  43. // Note: Although |verified_cert| will match the originally supplied
  44. // certificate to be validated, the results of intermediate_buffers()
  45. // may be substantially different, both in order and in content, then the
  46. // originally supplied intermediates.
  47. //
  48. // In the event of validation failures, this may contain the originally
  49. // supplied certificate chain or a partially constructed path, depending on
  50. // the implementation.
  51. //
  52. // In the event of validation success, the trust anchor will be
  53. // |verified_cert->intermediate_buffers().back()| if
  54. // there was a certificate chain to the trust anchor, and will
  55. // be |verified_cert->cert_buffer()| if the certificate was
  56. // the trust anchor.
  57. scoped_refptr<X509Certificate> verified_cert;
  58. // Bitmask of CERT_STATUS_* from net/cert/cert_status_flags.h. Note that
  59. // these status flags apply to the certificate chain returned in
  60. // |verified_cert|, rather than the originally supplied certificate
  61. // chain.
  62. CertStatus cert_status;
  63. // Hash algorithms used by the certificate chain, excluding the trust
  64. // anchor.
  65. bool has_sha1;
  66. bool has_sha1_leaf;
  67. // If the certificate was successfully verified then this contains the
  68. // hashes for all of the SubjectPublicKeyInfos of the chain (target,
  69. // intermediates, and trust anchor)
  70. //
  71. // The ordering of the hashes in this vector is unspecified. Both the SHA1
  72. // and SHA256 hash will be present for each certificate.
  73. HashValueVector public_key_hashes;
  74. // is_issued_by_known_root is true if we recognise the root CA as a standard
  75. // root. If it isn't then it's probably the case that this certificate was
  76. // generated by a MITM proxy whose root has been installed locally. This is
  77. // meaningless if the certificate was not trusted.
  78. bool is_issued_by_known_root;
  79. // is_issued_by_additional_trust_anchor is true if the root CA used for this
  80. // verification came from the list of additional trust anchors.
  81. bool is_issued_by_additional_trust_anchor;
  82. // Verification of stapled OCSP response, if present.
  83. OCSPVerifyResult ocsp_result;
  84. // `scts` contains the result of verifying any provided or embedded SCTs for
  85. // this certificate against the set of known logs. Consumers should not simply
  86. // check this for the presence of a successfully verified SCT to determine CT
  87. // compliance. Instead look at `policy_compliance`.
  88. SignedCertificateTimestampAndStatusList scts;
  89. // The result of evaluating whether the certificate complies with the
  90. // Certificate Transparency policy.
  91. ct::CTPolicyCompliance policy_compliance;
  92. };
  93. } // namespace net
  94. #endif // NET_CERT_CERT_VERIFY_RESULT_H_