| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 new chromeos::CertVerifyProcChromeOS())); | 531 new chromeos::CertVerifyProcChromeOS())); |
| 532 #else | 532 #else |
| 533 globals_->cert_verifier = net::CertVerifier::CreateDefault(); | 533 globals_->cert_verifier = net::CertVerifier::CreateDefault(); |
| 534 #endif | 534 #endif |
| 535 | 535 |
| 536 globals_->transport_security_state.reset(new net::TransportSecurityState()); | 536 globals_->transport_security_state.reset(new net::TransportSecurityState()); |
| 537 | 537 |
| 538 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( | 538 std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( |
| 539 net::ct::CreateLogVerifiersForKnownLogs()); | 539 net::ct::CreateLogVerifiersForKnownLogs()); |
| 540 | 540 |
| 541 // Add logs from command line | |
| 542 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { | |
| 543 std::string switch_value = command_line.GetSwitchValueASCII( | |
| 544 switches::kCertificateTransparencyLog); | |
| 545 for (const base::StringPiece& curr_log : base::SplitStringPiece( | |
| 546 switch_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
| 547 std::vector<std::string> log_metadata = base::SplitString( | |
| 548 curr_log, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 549 CHECK_GE(log_metadata.size(), 3u) | |
| 550 << "CT log metadata missing: Switch format is " | |
| 551 << "'description:base64_key:url_without_schema[:dns_domain]'."; | |
| 552 std::string log_description(log_metadata[0]); | |
| 553 std::string log_url(std::string("https://") + log_metadata[2]); | |
| 554 std::string log_dns_domain; | |
| 555 if (log_metadata.size() >= 4) | |
| 556 log_dns_domain = log_metadata[3]; | |
| 557 std::string ct_public_key_data; | |
| 558 CHECK(base::Base64Decode(log_metadata[1], &ct_public_key_data)) | |
| 559 << "Unable to decode CT public key."; | |
| 560 scoped_refptr<const net::CTLogVerifier> external_log_verifier( | |
| 561 net::CTLogVerifier::Create(ct_public_key_data, log_description, | |
| 562 log_url, log_dns_domain)); | |
| 563 CHECK(external_log_verifier) << "Unable to parse CT public key."; | |
| 564 VLOG(1) << "Adding log with description " << log_description; | |
| 565 ct_logs.push_back(external_log_verifier); | |
| 566 } | |
| 567 } | |
| 568 | |
| 569 globals_->ct_logs.assign(ct_logs.begin(), ct_logs.end()); | 541 globals_->ct_logs.assign(ct_logs.begin(), ct_logs.end()); |
| 570 | 542 |
| 571 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); | 543 net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
| 572 globals_->cert_transparency_verifier.reset(ct_verifier); | 544 globals_->cert_transparency_verifier.reset(ct_verifier); |
| 573 // Add built-in logs | 545 // Add built-in logs |
| 574 ct_verifier->AddLogs(globals_->ct_logs); | 546 ct_verifier->AddLogs(globals_->ct_logs); |
| 575 | 547 |
| 576 ct_tree_tracker_.reset( | 548 ct_tree_tracker_.reset( |
| 577 new certificate_transparency::TreeStateTracker(globals_->ct_logs)); | 549 new certificate_transparency::TreeStateTracker(globals_->ct_logs)); |
| 578 // Register the ct_tree_tracker_ as observer for new STHs. | 550 // Register the ct_tree_tracker_ as observer for new STHs. |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 964 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 993 // system URLRequestContext too. There's no reason this should be tied to a | 965 // system URLRequestContext too. There's no reason this should be tied to a |
| 994 // profile. | 966 // profile. |
| 995 return context; | 967 return context; |
| 996 } | 968 } |
| 997 | 969 |
| 998 const metrics::UpdateUsagePrefCallbackType& | 970 const metrics::UpdateUsagePrefCallbackType& |
| 999 IOThread::GetMetricsDataUseForwarder() { | 971 IOThread::GetMetricsDataUseForwarder() { |
| 1000 return metrics_data_use_forwarder_; | 972 return metrics_data_use_forwarder_; |
| 1001 } | 973 } |
| OLD | NEW |