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

Unified Diff: net/http/transport_security_state.cc

Issue 2102783003: Add enterprise policy to exempt hosts from Certificate Transparency (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@enterprise_ct
Patch Set: Comment tweak to remove () 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/http/transport_security_state.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/transport_security_state.cc
diff --git a/net/http/transport_security_state.cc b/net/http/transport_security_state.cc
index 34039cecb05775f0e2ee3c57c6925ffdc80b5736..30d352712f27739fb9aecbd9a72e56680e93b60c 100644
--- a/net/http/transport_security_state.cc
+++ b/net/http/transport_security_state.cc
@@ -41,6 +41,12 @@ const size_t kMaxHPKPReportCacheEntries = 50;
const int kTimeToRememberHPKPReportsMins = 60;
const size_t kReportCacheKeyLength = 16;
+// Override for ShouldRequireCT() for unit tests. Possible values:
+// -1: Unless a delegate says otherwise, do not require CT.
+// 0: Use the default implementation (e.g. production)
+// 1: Unless a delegate says otherwise, require CT.
+int g_ct_required_for_testing = 0;
+
void RecordUMAForHPKPReportFailure(const GURL& report_uri, int net_error) {
UMA_HISTOGRAM_SPARSE_SLOWLY("Net.PublicKeyPinReportSendingFailure",
net_error);
@@ -712,6 +718,10 @@ bool TransportSecurityState::ShouldRequireCT(
if (ct_required != CTRequirementLevel::DEFAULT)
return ct_required == CTRequirementLevel::REQUIRED;
+ // Allow unittests to override the default result.
+ if (g_ct_required_for_testing)
+ return g_ct_required_for_testing == 1;
+
return false;
}
@@ -1135,6 +1145,15 @@ void TransportSecurityState::ReportUMAOnPinFailure(const std::string& host) {
}
// static
+void TransportSecurityState::SetShouldRequireCTForTesting(bool* required) {
+ if (!required) {
+ g_ct_required_for_testing = 0;
+ return;
+ }
+ g_ct_required_for_testing = *required ? 1 : -1;
+}
+
+// static
bool TransportSecurityState::IsBuildTimely() {
const base::Time build_time = base::GetBuildTime();
// We consider built-in information to be timely for 10 weeks.
« no previous file with comments | « net/http/transport_security_state.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698