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