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

Side by Side Diff: components/certificate_transparency/tree_state_tracker.cc

Issue 2017563002: Add Certificate Transparency logs auditing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compilation issue Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/certificate_transparency/tree_state_tracker.h" 5 #include "components/certificate_transparency/tree_state_tracker.h"
6 6
7 #include "base/feature_list.h"
8 #include "base/memory/ptr_util.h"
9 #include "components/certificate_transparency/log_dns_client.h"
7 #include "components/certificate_transparency/single_tree_tracker.h" 10 #include "components/certificate_transparency/single_tree_tracker.h"
11 #include "net/base/network_change_notifier.h"
8 #include "net/cert/ct_log_verifier.h" 12 #include "net/cert/ct_log_verifier.h"
9 #include "net/cert/signed_certificate_timestamp.h" 13 #include "net/cert/signed_certificate_timestamp.h"
10 #include "net/cert/signed_tree_head.h" 14 #include "net/cert/signed_tree_head.h"
11 #include "net/cert/x509_certificate.h" 15 #include "net/cert/x509_certificate.h"
16 #include "net/dns/dns_client.h"
17 #include "net/dns/dns_config_service.h"
18 #include "net/log/net_log.h"
12 19
13 using net::X509Certificate; 20 using net::X509Certificate;
14 using net::CTLogVerifier; 21 using net::CTLogVerifier;
15 using net::ct::SignedCertificateTimestamp; 22 using net::ct::SignedCertificateTimestamp;
16 using net::ct::SignedTreeHead; 23 using net::ct::SignedTreeHead;
17 24
25 namespace {
26 const size_t kMaxConcurrentDnsQueries = 1;
27 }
28
18 namespace certificate_transparency { 29 namespace certificate_transparency {
19 30
31 // Enables or disables auditing Certificate Transparency logs over DNS.
32 const base::Feature kCTLogAuditing = {"CertificateTransparencyLogAuditing",
33 base::FEATURE_DISABLED_BY_DEFAULT};
34
20 TreeStateTracker::TreeStateTracker( 35 TreeStateTracker::TreeStateTracker(
21 std::vector<scoped_refptr<const CTLogVerifier>> ct_logs) { 36 std::vector<scoped_refptr<const CTLogVerifier>> ct_logs) {
22 for (const auto& log : ct_logs) 37 if (!base::FeatureList::IsEnabled(kCTLogAuditing))
23 tree_trackers_[log->key_id()].reset(new SingleTreeTracker(log)); 38 return;
39
40 //TODO(eranm): Hook up a real NetLog this way:
Ryan Sleevi 2017/01/20 12:53:21 // TODO(eranm): (add space)
Eran Messeri 2017/01/23 16:45:47 Done.
41 // Pass in a NetLog from the IOThread when creating the TreeStateTracker:
42 // In, chrome/browser/io_thread.cc, where the TreeStateTracker is created,
43 // there's already an initialized ChromeNetLog instance (net_log_).
44 //
45 // A NetLog instance would be passed into the TreeStateTracker c'tor.
46 // Here, a NetLogWithSource will be created from the NetLog instance (after
47 // adding a new source type in net_log_source_type_list.h, to indicate which
48 // dns queries are related to CT inclusion proof fetching) by invoking
49 // NetLogWithSource::Make.
Ryan Sleevi 2017/01/20 12:53:21 Let's drop this comment, if anything because it's
Eran Messeri 2017/01/23 16:45:47 Done.
50 net::NetLogWithSource net_log;
51 std::unique_ptr<net::DnsClient> dns_client =
52 net::DnsClient::CreateClient(net_log.net_log());
53 dns_client_ = base::MakeUnique<LogDnsClient>(std::move(dns_client), net_log,
54 kMaxConcurrentDnsQueries);
55
56 for (const auto& log : ct_logs) {
57 tree_trackers_[log->key_id()].reset(
58 new SingleTreeTracker(log, dns_client_.get()));
59 }
24 } 60 }
25 61
26 TreeStateTracker::~TreeStateTracker() {} 62 TreeStateTracker::~TreeStateTracker() {}
27 63
28 void TreeStateTracker::OnSCTVerified(X509Certificate* cert, 64 void TreeStateTracker::OnSCTVerified(X509Certificate* cert,
29 const SignedCertificateTimestamp* sct) { 65 const SignedCertificateTimestamp* sct) {
30 auto it = tree_trackers_.find(sct->log_id); 66 auto it = tree_trackers_.find(sct->log_id);
31 // Ignore if the SCT is from an unknown log. 67 // Ignore if the SCT is from an unknown log.
32 if (it == tree_trackers_.end()) 68 if (it == tree_trackers_.end())
33 return; 69 return;
34 70
35 it->second->OnSCTVerified(cert, sct); 71 it->second->OnSCTVerified(cert, sct);
36 } 72 }
37 73
38 void TreeStateTracker::NewSTHObserved(const SignedTreeHead& sth) { 74 void TreeStateTracker::NewSTHObserved(const SignedTreeHead& sth) {
39 auto it = tree_trackers_.find(sth.log_id); 75 auto it = tree_trackers_.find(sth.log_id);
40 // Is the STH from a known log? Since STHs can be provided from external 76 // Is the STH from a known log? Since STHs can be provided from external
41 // sources for logs not yet recognized by this client, return, rather than 77 // sources for logs not yet recognized by this client, return, rather than
42 // DCHECK. 78 // DCHECK.
43 if (it == tree_trackers_.end()) 79 if (it == tree_trackers_.end())
44 return; 80 return;
45 81
46 it->second->NewSTHObserved(sth); 82 it->second->NewSTHObserved(sth);
47 } 83 }
48 84
49 } // namespace certificate_transparency 85 } // namespace certificate_transparency
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698