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

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

Issue 86503002: Certificate Transparency: Logging SCTs to the NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgot one file. Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/cert/multi_log_ct_verifier.h ('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 "base/bind.h"
8 #include "base/callback_helpers.h"
7 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/base/net_log.h"
8 #include "net/cert/ct_log_verifier.h" 11 #include "net/cert/ct_log_verifier.h"
9 #include "net/cert/ct_objects_extractor.h" 12 #include "net/cert/ct_objects_extractor.h"
10 #include "net/cert/ct_serialization.h" 13 #include "net/cert/ct_serialization.h"
14 #include "net/cert/ct_signed_certificate_timestamp_log_param.h"
11 #include "net/cert/ct_verify_result.h" 15 #include "net/cert/ct_verify_result.h"
12 #include "net/cert/x509_certificate.h" 16 #include "net/cert/x509_certificate.h"
13 17
14 namespace net { 18 namespace net {
15 19
16 MultiLogCTVerifier::MultiLogCTVerifier() { } 20 MultiLogCTVerifier::MultiLogCTVerifier() { }
17 21
18 MultiLogCTVerifier::~MultiLogCTVerifier() { } 22 MultiLogCTVerifier::~MultiLogCTVerifier() { }
19 23
20 void MultiLogCTVerifier::AddLog(scoped_ptr<CTLogVerifier> log_verifier) { 24 void MultiLogCTVerifier::AddLog(scoped_ptr<CTLogVerifier> log_verifier) {
21 DCHECK(log_verifier); 25 DCHECK(log_verifier);
22 if (!log_verifier) 26 if (!log_verifier)
23 return; 27 return;
24 28
25 linked_ptr<CTLogVerifier> log(log_verifier.release()); 29 linked_ptr<CTLogVerifier> log(log_verifier.release());
26 logs_[log->key_id()] = log; 30 logs_[log->key_id()] = log;
27 } 31 }
28 32
29 int MultiLogCTVerifier::Verify( 33 int MultiLogCTVerifier::Verify(
30 X509Certificate* cert, 34 X509Certificate* cert,
31 const std::string& sct_list_from_ocsp, 35 const std::string& sct_list_from_ocsp,
32 const std::string& sct_list_from_tls_extension, 36 const std::string& sct_list_from_tls_extension,
33 ct::CTVerifyResult* result) { 37 ct::CTVerifyResult* result,
38 const BoundNetLog& net_log) {
34 DCHECK(cert); 39 DCHECK(cert);
35 DCHECK(result); 40 DCHECK(result);
36 41
37 result->verified_scts.clear(); 42 result->verified_scts.clear();
38 result->invalid_scts.clear(); 43 result->invalid_scts.clear();
39 result->unknown_logs_scts.clear(); 44 result->unknown_logs_scts.clear();
40 45
41 bool has_verified_scts = false; 46 bool has_verified_scts = false;
42 47
43 std::string embedded_scts; 48 std::string embedded_scts;
44 if (!cert->GetIntermediateCertificates().empty() && 49 if (!cert->GetIntermediateCertificates().empty() &&
45 ct::ExtractEmbeddedSCTList( 50 ct::ExtractEmbeddedSCTList(
46 cert->os_cert_handle(), 51 cert->os_cert_handle(),
47 &embedded_scts)) { 52 &embedded_scts)) {
48 ct::LogEntry precert_entry; 53 ct::LogEntry precert_entry;
49 54
50 has_verified_scts = 55 has_verified_scts =
51 ct::GetPrecertLogEntry( 56 ct::GetPrecertLogEntry(
52 cert->os_cert_handle(), 57 cert->os_cert_handle(),
53 cert->GetIntermediateCertificates().front(), 58 cert->GetIntermediateCertificates().front(),
54 &precert_entry) && 59 &precert_entry) &&
55 VerifySCTs( 60 VerifySCTs(
56 embedded_scts, 61 embedded_scts,
57 precert_entry, 62 precert_entry,
58 ct::SignedCertificateTimestamp::SCT_EMBEDDED, 63 ct::SignedCertificateTimestamp::SCT_EMBEDDED,
59 result); 64 result);
60 } 65 }
61 66
67 // Log to Net Log, after extracting embedded SCTs but before
68 // possibly failing on X.509 entry creation.
69 NetLog::ParametersCallback net_log_callback =
70 base::Bind(&NetLogRawSignedCertificateTimestampCallback,
71 &embedded_scts, &sct_list_from_ocsp, &sct_list_from_tls_extension);
72
73 net_log.AddEvent(
74 NetLog::TYPE_SIGNED_CERTIFICATE_TIMESTAMPS_RECEIVED,
75 net_log_callback);
76
62 ct::LogEntry x509_entry; 77 ct::LogEntry x509_entry;
63 if (ct::GetX509LogEntry(cert->os_cert_handle(), &x509_entry)) { 78 if (ct::GetX509LogEntry(cert->os_cert_handle(), &x509_entry)) {
64 has_verified_scts |= VerifySCTs( 79 has_verified_scts |= VerifySCTs(
65 sct_list_from_ocsp, 80 sct_list_from_ocsp,
66 x509_entry, 81 x509_entry,
67 ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE, 82 ct::SignedCertificateTimestamp::SCT_FROM_OCSP_RESPONSE,
68 result); 83 result);
69 84
70 has_verified_scts |= VerifySCTs( 85 has_verified_scts |= VerifySCTs(
71 sct_list_from_tls_extension, 86 sct_list_from_tls_extension,
72 x509_entry, 87 x509_entry,
73 ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION, 88 ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION,
74 result); 89 result);
75 } 90 }
76 91
92 NetLog::ParametersCallback net_log_checked_callback =
93 base::Bind(&NetLogSignedCertificateTimestampCallback, result);
94
95 net_log.AddEvent(
96 NetLog::TYPE_SIGNED_CERTIFICATE_TIMESTAMPS_CHECKED,
97 net_log_checked_callback);
98
77 if (has_verified_scts) 99 if (has_verified_scts)
78 return OK; 100 return OK;
79 101
80 return ERR_CT_NO_SCTS_VERIFIED_OK; 102 return ERR_CT_NO_SCTS_VERIFIED_OK;
81 } 103 }
82 104
83 bool MultiLogCTVerifier::VerifySCTs( 105 bool MultiLogCTVerifier::VerifySCTs(
84 const std::string& encoded_sct_list, 106 const std::string& encoded_sct_list,
85 const ct::LogEntry& expected_entry, 107 const ct::LogEntry& expected_entry,
86 ct::SignedCertificateTimestamp::Origin origin, 108 ct::SignedCertificateTimestamp::Origin origin,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DVLOG(1) << "SCT is from the future!"; 158 DVLOG(1) << "SCT is from the future!";
137 result->invalid_scts.push_back(sct); 159 result->invalid_scts.push_back(sct);
138 return false; 160 return false;
139 } 161 }
140 162
141 result->verified_scts.push_back(sct); 163 result->verified_scts.push_back(sct);
142 return true; 164 return true;
143 } 165 }
144 166
145 } // namespace net 167 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/multi_log_ct_verifier.h ('k') | net/cert/multi_log_ct_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698