Chromium Code Reviews| 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 "net/http/transport_security_state.h" | 5 #include "net/http/transport_security_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 | 385 |
| 386 private: | 386 private: |
| 387 const uint8_t* const tree_; | 387 const uint8_t* const tree_; |
| 388 const size_t tree_bytes_; | 388 const size_t tree_bytes_; |
| 389 }; | 389 }; |
| 390 | 390 |
| 391 // PreloadResult is the result of resolving a specific name in the preloaded | 391 // PreloadResult is the result of resolving a specific name in the preloaded |
| 392 // data. | 392 // data. |
| 393 struct PreloadResult { | 393 struct PreloadResult { |
| 394 uint32_t pinset_id; | 394 uint32_t pinset_id; |
| 395 uint32_t domain_id; | |
| 396 // hostname_offset contains the number of bytes from the start of the given | 395 // hostname_offset contains the number of bytes from the start of the given |
| 397 // hostname where the name of the matching entry starts. | 396 // hostname where the name of the matching entry starts. |
| 398 size_t hostname_offset; | 397 size_t hostname_offset; |
| 399 bool sts_include_subdomains; | 398 bool sts_include_subdomains; |
| 400 bool pkp_include_subdomains; | 399 bool pkp_include_subdomains; |
| 401 bool force_https; | 400 bool force_https; |
| 402 bool has_pins; | 401 bool has_pins; |
| 403 bool expect_ct; | 402 bool expect_ct; |
| 404 uint32_t expect_ct_report_uri_id; | 403 uint32_t expect_ct_report_uri_id; |
| 405 bool expect_staple; | 404 bool expect_staple; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 if (c == kEndOfString) { | 516 if (c == kEndOfString) { |
| 518 PreloadResult tmp; | 517 PreloadResult tmp; |
| 519 if (!reader.Next(&tmp.sts_include_subdomains) || | 518 if (!reader.Next(&tmp.sts_include_subdomains) || |
| 520 !reader.Next(&tmp.force_https) || !reader.Next(&tmp.has_pins)) { | 519 !reader.Next(&tmp.force_https) || !reader.Next(&tmp.has_pins)) { |
| 521 return false; | 520 return false; |
| 522 } | 521 } |
| 523 | 522 |
| 524 tmp.pkp_include_subdomains = tmp.sts_include_subdomains; | 523 tmp.pkp_include_subdomains = tmp.sts_include_subdomains; |
| 525 | 524 |
| 526 if (tmp.has_pins) { | 525 if (tmp.has_pins) { |
| 526 uint32_t unused_domain_id; | |
| 527 if (!reader.Read(4, &tmp.pinset_id) || | 527 if (!reader.Read(4, &tmp.pinset_id) || |
| 528 !reader.Read(9, &tmp.domain_id) || | 528 !reader.Read(9, &unused_domain_id) || |
|
davidben
2016/11/01 17:20:22
Could you file a bug to get rid of this and link i
estark
2016/11/01 17:25:47
Done (bug 661206).
| |
| 529 (!tmp.sts_include_subdomains && | 529 (!tmp.sts_include_subdomains && |
| 530 !reader.Next(&tmp.pkp_include_subdomains))) { | 530 !reader.Next(&tmp.pkp_include_subdomains))) { |
| 531 return false; | 531 return false; |
| 532 } | 532 } |
| 533 } | 533 } |
| 534 | 534 |
| 535 if (!reader.Next(&tmp.expect_ct)) | 535 if (!reader.Next(&tmp.expect_ct)) |
| 536 return false; | 536 return false; |
| 537 | 537 |
| 538 if (tmp.expect_ct) { | 538 if (tmp.expect_ct) { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 PKPStatus pin_validity = CheckPublicKeyPinsImpl( | 771 PKPStatus pin_validity = CheckPublicKeyPinsImpl( |
| 772 host_port_pair, is_issued_by_known_root, public_key_hashes, | 772 host_port_pair, is_issued_by_known_root, public_key_hashes, |
| 773 served_certificate_chain, validated_certificate_chain, report_status, | 773 served_certificate_chain, validated_certificate_chain, report_status, |
| 774 pinning_failure_log); | 774 pinning_failure_log); |
| 775 | 775 |
| 776 // Don't track statistics when a local trust anchor would override the pinning | 776 // Don't track statistics when a local trust anchor would override the pinning |
| 777 // anyway. | 777 // anyway. |
| 778 if (!is_issued_by_known_root) | 778 if (!is_issued_by_known_root) |
| 779 return pin_validity; | 779 return pin_validity; |
| 780 | 780 |
| 781 if (pin_validity == PKPStatus::VIOLATED) { | |
| 782 LOG(ERROR) << *pinning_failure_log; | |
| 783 ReportUMAOnPinFailure(host_port_pair.host()); | |
| 784 } | |
| 785 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", | 781 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", |
| 786 pin_validity == PKPStatus::OK); | 782 pin_validity == PKPStatus::OK); |
| 787 return pin_validity; | 783 return pin_validity; |
| 788 } | 784 } |
| 789 | 785 |
| 790 void TransportSecurityState::CheckExpectStaple( | 786 void TransportSecurityState::CheckExpectStaple( |
| 791 const HostPortPair& host_port_pair, | 787 const HostPortPair& host_port_pair, |
| 792 const SSLInfo& ssl_info, | 788 const SSLInfo& ssl_info, |
| 793 const std::string& ocsp_response) { | 789 const std::string& ocsp_response) { |
| 794 DCHECK(CalledOnValidThread()); | 790 DCHECK(CalledOnValidThread()); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1347 UMA_HISTOGRAM_ENUMERATION("Net.ExpectCTHeaderResult", result, | 1343 UMA_HISTOGRAM_ENUMERATION("Net.ExpectCTHeaderResult", result, |
| 1348 EXPECT_CT_HEADER_LAST + 1); | 1344 EXPECT_CT_HEADER_LAST + 1); |
| 1349 if (result != EXPECT_CT_HEADER_PROCESSED) | 1345 if (result != EXPECT_CT_HEADER_PROCESSED) |
| 1350 return; | 1346 return; |
| 1351 | 1347 |
| 1352 expect_ct_reporter_->OnExpectCTFailed(host_port_pair, state.report_uri, | 1348 expect_ct_reporter_->OnExpectCTFailed(host_port_pair, state.report_uri, |
| 1353 ssl_info); | 1349 ssl_info); |
| 1354 } | 1350 } |
| 1355 | 1351 |
| 1356 // static | 1352 // static |
| 1357 void TransportSecurityState::ReportUMAOnPinFailure(const std::string& host) { | |
| 1358 PreloadResult result; | |
| 1359 if (!DecodeHSTSPreload(host, &result) || | |
| 1360 !result.has_pins) { | |
| 1361 return; | |
| 1362 } | |
| 1363 | |
| 1364 DCHECK(result.domain_id != DOMAIN_NOT_PINNED); | |
| 1365 | |
| 1366 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 1367 "Net.PublicKeyPinFailureDomain", result.domain_id); | |
| 1368 } | |
| 1369 | |
| 1370 // static | |
| 1371 void TransportSecurityState::SetShouldRequireCTForTesting(bool* required) { | 1353 void TransportSecurityState::SetShouldRequireCTForTesting(bool* required) { |
| 1372 if (!required) { | 1354 if (!required) { |
| 1373 g_ct_required_for_testing = 0; | 1355 g_ct_required_for_testing = 0; |
| 1374 return; | 1356 return; |
| 1375 } | 1357 } |
| 1376 g_ct_required_for_testing = *required ? 1 : -1; | 1358 g_ct_required_for_testing = *required ? 1 : -1; |
| 1377 } | 1359 } |
| 1378 | 1360 |
| 1379 // static | 1361 // static |
| 1380 bool TransportSecurityState::IsBuildTimely() { | 1362 bool TransportSecurityState::IsBuildTimely() { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1659 TransportSecurityState::PKPStateIterator::PKPStateIterator( | 1641 TransportSecurityState::PKPStateIterator::PKPStateIterator( |
| 1660 const TransportSecurityState& state) | 1642 const TransportSecurityState& state) |
| 1661 : iterator_(state.enabled_pkp_hosts_.begin()), | 1643 : iterator_(state.enabled_pkp_hosts_.begin()), |
| 1662 end_(state.enabled_pkp_hosts_.end()) { | 1644 end_(state.enabled_pkp_hosts_.end()) { |
| 1663 } | 1645 } |
| 1664 | 1646 |
| 1665 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { | 1647 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { |
| 1666 } | 1648 } |
| 1667 | 1649 |
| 1668 } // namespace | 1650 } // namespace |
| OLD | NEW |