• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_CERT_CT_POLICY_ENFORCER_H_
6 #define NET_CERT_CT_POLICY_ENFORCER_H_
7 
8 #include <stddef.h>
9 
10 #include "net/base/net_export.h"
11 #include "net/cert/signed_certificate_timestamp.h"
12 
13 namespace net {
14 
15 class NetLogWithSource;
16 
17 namespace ct {
18 enum class CTPolicyCompliance;
19 }  // namespace ct
20 
21 class X509Certificate;
22 
23 // Interface for checking whether or not a given certificate conforms to any
24 // policies an application may have regarding Certificate Transparency.
25 //
26 // See //net/docs/certificate-transparency.md for more details regarding the
27 // usage of CT in //net and risks that may exist when defining a CT policy.
28 class NET_EXPORT CTPolicyEnforcer {
29  public:
30   virtual ~CTPolicyEnforcer() = default;
31 
32   // Returns the CT certificate policy compliance status for a given
33   // certificate and collection of SCTs.
34   // |cert| is the certificate for which to check compliance, and
35   // ||verified_scts| contains any/all SCTs associated with |cert| that
36   // |have been verified (well-formed, issued by known logs, and
37   // |applying to |cert|).
38   virtual ct::CTPolicyCompliance CheckCompliance(
39       X509Certificate* cert,
40       const ct::SCTList& verified_scts,
41       const NetLogWithSource& net_log) = 0;
42 };
43 
44 // A default implementation of Certificate Transparency policies that is
45 // intended for use in applications without auto-update capabilities.
46 //
47 // See //net/docs/certificate-transparency.md for more details.
48 class NET_EXPORT DefaultCTPolicyEnforcer : public net::CTPolicyEnforcer {
49  public:
50   DefaultCTPolicyEnforcer() = default;
51   ~DefaultCTPolicyEnforcer() override = default;
52 
53   ct::CTPolicyCompliance CheckCompliance(
54       X509Certificate* cert,
55       const ct::SCTList& verified_scts,
56       const NetLogWithSource& net_log) override;
57 };
58 
59 }  // namespace net
60 
61 #endif  // NET_CERT_CT_POLICY_ENFORCER_H_
62