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

Side by Side Diff: net/cert/multi_log_ct_verifier.cc

Issue 2225223002: Certificate Transparency: Change CTVerifyResult to have a single list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NetLog int to string Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/cert/ct_verify_result.cc ('k') | net/cert/multi_log_ct_verifier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/multi_log_ct_verifier.h" 5 #include "net/cert/multi_log_ct_verifier.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 28 matching lines...) Expand all
39 ct::SignedCertificateTimestamp::SCT_ORIGIN_MAX); 39 ct::SignedCertificateTimestamp::SCT_ORIGIN_MAX);
40 } 40 }
41 41
42 // Count the number of SCTs that were available for each SSL connection 42 // Count the number of SCTs that were available for each SSL connection
43 // (including SCTs embedded in the certificate). 43 // (including SCTs embedded in the certificate).
44 // This metric would allow measuring: 44 // This metric would allow measuring:
45 // * Of all SSL connections, how many had SCTs available for validation. 45 // * Of all SSL connections, how many had SCTs available for validation.
46 // * When SCTs are available, how many are available per connection. 46 // * When SCTs are available, how many are available per connection.
47 void LogNumSCTsToUMA(const ct::CTVerifyResult& result) { 47 void LogNumSCTsToUMA(const ct::CTVerifyResult& result) {
48 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.CertificateTransparency.SCTsPerConnection", 48 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.CertificateTransparency.SCTsPerConnection",
49 result.invalid_scts.size() + 49 result.scts.size(), 1, 10, 11);
50 result.verified_scts.size() + 50 }
51 result.unknown_logs_scts.size(), 51
52 1, 52 void AddSCTAndLogStatus(scoped_refptr<ct::SignedCertificateTimestamp> sct,
53 10, 53 ct::SCTVerifyStatus status,
54 11); 54 SignedCertificateTimestampAndStatusList* sct_list) {
55 LogSCTStatusToUMA(status);
56 sct_list->push_back(SignedCertificateTimestampAndStatus(sct, status));
55 } 57 }
56 58
57 } // namespace 59 } // namespace
58 60
59 MultiLogCTVerifier::MultiLogCTVerifier() : observer_(nullptr) { 61 MultiLogCTVerifier::MultiLogCTVerifier() : observer_(nullptr) {
60 } 62 }
61 63
62 MultiLogCTVerifier::~MultiLogCTVerifier() { } 64 MultiLogCTVerifier::~MultiLogCTVerifier() { }
63 65
64 void MultiLogCTVerifier::AddLogs( 66 void MultiLogCTVerifier::AddLogs(
(...skipping 10 matching lines...) Expand all
75 77
76 int MultiLogCTVerifier::Verify( 78 int MultiLogCTVerifier::Verify(
77 X509Certificate* cert, 79 X509Certificate* cert,
78 const std::string& stapled_ocsp_response, 80 const std::string& stapled_ocsp_response,
79 const std::string& sct_list_from_tls_extension, 81 const std::string& sct_list_from_tls_extension,
80 ct::CTVerifyResult* result, 82 ct::CTVerifyResult* result,
81 const BoundNetLog& net_log) { 83 const BoundNetLog& net_log) {
82 DCHECK(cert); 84 DCHECK(cert);
83 DCHECK(result); 85 DCHECK(result);
84 86
85 result->verified_scts.clear(); 87 result->scts.clear();
86 result->invalid_scts.clear();
87 result->unknown_logs_scts.clear();
88 88
89 bool has_verified_scts = false; 89 bool has_verified_scts = false;
90 90
91 std::string embedded_scts; 91 std::string embedded_scts;
92 if (!cert->GetIntermediateCertificates().empty() && 92 if (!cert->GetIntermediateCertificates().empty() &&
93 ct::ExtractEmbeddedSCTList( 93 ct::ExtractEmbeddedSCTList(
94 cert->os_cert_handle(), 94 cert->os_cert_handle(),
95 &embedded_scts)) { 95 &embedded_scts)) {
96 ct::LogEntry precert_entry; 96 ct::LogEntry precert_entry;
97 97
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 184
185 bool MultiLogCTVerifier::VerifySingleSCT( 185 bool MultiLogCTVerifier::VerifySingleSCT(
186 scoped_refptr<ct::SignedCertificateTimestamp> sct, 186 scoped_refptr<ct::SignedCertificateTimestamp> sct,
187 const ct::LogEntry& expected_entry, 187 const ct::LogEntry& expected_entry,
188 X509Certificate* cert, 188 X509Certificate* cert,
189 ct::CTVerifyResult* result) { 189 ct::CTVerifyResult* result) {
190 // Assume this SCT is untrusted until proven otherwise. 190 // Assume this SCT is untrusted until proven otherwise.
191 const auto& it = logs_.find(sct->log_id); 191 const auto& it = logs_.find(sct->log_id);
192 if (it == logs_.end()) { 192 if (it == logs_.end()) {
193 DVLOG(1) << "SCT does not match any known log."; 193 DVLOG(1) << "SCT does not match any known log.";
194 result->unknown_logs_scts.push_back(sct); 194 AddSCTAndLogStatus(sct, ct::SCT_STATUS_LOG_UNKNOWN, &(result->scts));
195 LogSCTStatusToUMA(ct::SCT_STATUS_LOG_UNKNOWN);
196 return false; 195 return false;
197 } 196 }
198 197
199 sct->log_description = it->second->description(); 198 sct->log_description = it->second->description();
200 199
201 if (!it->second->Verify(expected_entry, *sct.get())) { 200 if (!it->second->Verify(expected_entry, *sct.get())) {
202 DVLOG(1) << "Unable to verify SCT signature."; 201 DVLOG(1) << "Unable to verify SCT signature.";
203 result->invalid_scts.push_back(sct); 202 AddSCTAndLogStatus(sct, ct::SCT_STATUS_INVALID, &(result->scts));
204 LogSCTStatusToUMA(ct::SCT_STATUS_INVALID);
205 return false; 203 return false;
206 } 204 }
207 205
208 // SCT verified ok, just make sure the timestamp is legitimate. 206 // SCT verified ok, just make sure the timestamp is legitimate.
209 if (sct->timestamp > base::Time::Now()) { 207 if (sct->timestamp > base::Time::Now()) {
210 DVLOG(1) << "SCT is from the future!"; 208 DVLOG(1) << "SCT is from the future!";
211 result->invalid_scts.push_back(sct); 209 AddSCTAndLogStatus(sct, ct::SCT_STATUS_INVALID, &(result->scts));
212 LogSCTStatusToUMA(ct::SCT_STATUS_INVALID);
213 return false; 210 return false;
214 } 211 }
215 212
216 LogSCTStatusToUMA(ct::SCT_STATUS_OK); 213 AddSCTAndLogStatus(sct, ct::SCT_STATUS_OK, &(result->scts));
217 result->verified_scts.push_back(sct);
218 if (observer_) 214 if (observer_)
219 observer_->OnSCTVerified(cert, sct.get()); 215 observer_->OnSCTVerified(cert, sct.get());
220 return true; 216 return true;
221 } 217 }
222 218
223 } // namespace net 219 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_verify_result.cc ('k') | net/cert/multi_log_ct_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698