Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Unified Diff: net/http/transport_security_state.h

Issue 2076363002: Introduce the ability to require CT for specific hosts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@require_ct_enforcer
Patch Set: Android is weird Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/cert_status_flags_list.h ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/transport_security_state.h
diff --git a/net/http/transport_security_state.h b/net/http/transport_security_state.h
index 168e87985f315194d9971ef3d3d830b4af65f1fd..a76f235e43be6e8c5a08b821752cfa06b42cf04c 100644
--- a/net/http/transport_security_state.h
+++ b/net/http/transport_security_state.h
@@ -49,6 +49,38 @@ class NET_EXPORT TransportSecurityState
virtual ~Delegate() {}
};
+ class NET_EXPORT RequireCTDelegate {
+ public:
+ // Provides a capability for altering the default handling of Certificate
+ // Transparency information, allowing it to be always required for some
+ // hosts, for some hosts to be opted out of the default policy, or
+ // allowing the TransportSecurityState to apply the default security
+ // policies.
+ enum class CTRequirementLevel {
+ // The host is required to always supply Certificate Transparency
+ // information that complies with the CT policy.
+ REQUIRED,
+
+ // The host is explicitly not required to supply Certificate
+ // Transparency information that complies with the CT policy.
+ NOT_REQUIRED,
+
+ // The delegate makes no statements, positive or negative, about
+ // requiring the host to supply Certificate Transparency information,
+ // allowing the default behaviour to happen.
+ DEFAULT,
+ };
+
+ // Called by the TransportSecurityState, allows the Delegate to override
+ // the default handling of Certificate Transparency requirements, if
+ // desired.
+ virtual CTRequirementLevel IsCTRequiredForHost(
+ const std::string& hostname) = 0;
+
+ protected:
+ virtual ~RequireCTDelegate() = default;
+ };
+
// A STSState describes the strict transport security state (required
// upgrade to HTTPS).
class NET_EXPORT STSState {
@@ -271,6 +303,17 @@ class NET_EXPORT TransportSecurityState
std::string* failure_log);
bool HasPublicKeyPins(const std::string& host);
+ // Returns true if connections to |host|, using the validated certificate
+ // |validated_certificate_chain|, are expected to be accompanied with
+ // valid Certificate Transparency information that complies with the
+ // connection's CTPolicyEnforcer.
+ //
+ // The behavior may be further be altered by setting a RequireCTDelegate
+ // via |SetRequireCTDelegate()|.
+ bool ShouldRequireCT(const std::string& host,
+ const X509Certificate* validated_certificate_chain,
+ const HashValueVector& hashes);
+
// Assign a |Delegate| for persisting the transport security state. If
// |NULL|, state will not be persisted. The caller retains
// ownership of |delegate|.
@@ -282,6 +325,16 @@ class NET_EXPORT TransportSecurityState
void SetExpectCTReporter(ExpectCTReporter* expect_ct_reporter);
+ // Assigns a delegate responsible for determining whether or not a
+ // connection to a given host should require Certificate Transparency
+ // information that complies with the CT policy provided by a
+ // CTPolicyEnforcer.
+ // If nullptr, no delegate will be consulted.
+ // The caller retains ownership of the |delegate|, and must persist for
+ // the lifetime of this object or until called with nullptr, whichever
+ // occurs first.
+ void SetRequireCTDelegate(RequireCTDelegate* delegate);
+
// Clears all dynamic data (e.g. HSTS and HPKP data).
//
// Does NOT persist changes using the Delegate, as this function is only
@@ -486,9 +539,9 @@ class NET_EXPORT TransportSecurityState
STSStateMap enabled_sts_hosts_;
PKPStateMap enabled_pkp_hosts_;
- Delegate* delegate_;
+ Delegate* delegate_ = nullptr;
- ReportSenderInterface* report_sender_;
+ ReportSenderInterface* report_sender_ = nullptr;
// True if static pins should be used.
bool enable_static_pins_;
@@ -499,7 +552,9 @@ class NET_EXPORT TransportSecurityState
// True if static expect-staple state should be used.
bool enable_static_expect_staple_;
- ExpectCTReporter* expect_ct_reporter_;
+ ExpectCTReporter* expect_ct_reporter_ = nullptr;
+
+ RequireCTDelegate* require_ct_delegate_ = nullptr;
// Keeps track of reports that have been sent recently for
// rate-limiting.
« no previous file with comments | « net/cert/cert_status_flags_list.h ('k') | net/http/transport_security_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698