| 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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 if (ssl_info.ocsp_result.response_status == OCSPVerifyResult::PROVIDED && | 806 if (ssl_info.ocsp_result.response_status == OCSPVerifyResult::PROVIDED && |
| 807 ssl_info.ocsp_result.revocation_status == OCSPRevocationStatus::GOOD) { | 807 ssl_info.ocsp_result.revocation_status == OCSPRevocationStatus::GOOD) { |
| 808 return; | 808 return; |
| 809 } | 809 } |
| 810 | 810 |
| 811 std::string serialized_report; | 811 std::string serialized_report; |
| 812 if (!SerializeExpectStapleReport(host_port_pair, ssl_info, ocsp_response, | 812 if (!SerializeExpectStapleReport(host_port_pair, ssl_info, ocsp_response, |
| 813 &serialized_report)) { | 813 &serialized_report)) { |
| 814 return; | 814 return; |
| 815 } | 815 } |
| 816 report_sender_->Send(expect_staple_state.report_uri, serialized_report); | 816 report_sender_->Send(expect_staple_state.report_uri, |
| 817 "application/json; charset=utf-8", serialized_report); |
| 817 } | 818 } |
| 818 | 819 |
| 819 bool TransportSecurityState::HasPublicKeyPins(const std::string& host) { | 820 bool TransportSecurityState::HasPublicKeyPins(const std::string& host) { |
| 820 PKPState dynamic_state; | 821 PKPState dynamic_state; |
| 821 if (GetDynamicPKPState(host, &dynamic_state)) | 822 if (GetDynamicPKPState(host, &dynamic_state)) |
| 822 return dynamic_state.HasPublicKeyPins(); | 823 return dynamic_state.HasPublicKeyPins(); |
| 823 | 824 |
| 824 STSState unused; | 825 STSState unused; |
| 825 PKPState static_pkp_state; | 826 PKPState static_pkp_state; |
| 826 if (GetStaticDomainState(host, &unused, &static_pkp_state)) { | 827 if (GetStaticDomainState(host, &unused, &static_pkp_state)) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 // |kTimeToRememberHPKPReportsMins|, which reduces load on servers and | 1065 // |kTimeToRememberHPKPReportsMins|, which reduces load on servers and |
| 1065 // also prevents accidental loops (a.com triggers a report to b.com | 1066 // also prevents accidental loops (a.com triggers a report to b.com |
| 1066 // which triggers a report to a.com). See section 2.1.4 of RFC 7469. | 1067 // which triggers a report to a.com). See section 2.1.4 of RFC 7469. |
| 1067 if (sent_reports_cache_.Get(report_cache_key, base::TimeTicks::Now())) | 1068 if (sent_reports_cache_.Get(report_cache_key, base::TimeTicks::Now())) |
| 1068 return PKPStatus::VIOLATED; | 1069 return PKPStatus::VIOLATED; |
| 1069 sent_reports_cache_.Put( | 1070 sent_reports_cache_.Put( |
| 1070 report_cache_key, true, base::TimeTicks::Now(), | 1071 report_cache_key, true, base::TimeTicks::Now(), |
| 1071 base::TimeTicks::Now() + | 1072 base::TimeTicks::Now() + |
| 1072 base::TimeDelta::FromMinutes(kTimeToRememberHPKPReportsMins)); | 1073 base::TimeDelta::FromMinutes(kTimeToRememberHPKPReportsMins)); |
| 1073 | 1074 |
| 1074 report_sender_->Send(pkp_state.report_uri, serialized_report); | 1075 report_sender_->Send(pkp_state.report_uri, "application/json; charset=utf-8", |
| 1076 serialized_report); |
| 1075 return PKPStatus::VIOLATED; | 1077 return PKPStatus::VIOLATED; |
| 1076 } | 1078 } |
| 1077 | 1079 |
| 1078 bool TransportSecurityState::GetStaticExpectCTState( | 1080 bool TransportSecurityState::GetStaticExpectCTState( |
| 1079 const std::string& host, | 1081 const std::string& host, |
| 1080 ExpectCTState* expect_ct_state) const { | 1082 ExpectCTState* expect_ct_state) const { |
| 1081 DCHECK(CalledOnValidThread()); | 1083 DCHECK(CalledOnValidThread()); |
| 1082 | 1084 |
| 1083 if (!IsBuildTimely()) | 1085 if (!IsBuildTimely()) |
| 1084 return false; | 1086 return false; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 TransportSecurityState::PKPStateIterator::PKPStateIterator( | 1626 TransportSecurityState::PKPStateIterator::PKPStateIterator( |
| 1625 const TransportSecurityState& state) | 1627 const TransportSecurityState& state) |
| 1626 : iterator_(state.enabled_pkp_hosts_.begin()), | 1628 : iterator_(state.enabled_pkp_hosts_.begin()), |
| 1627 end_(state.enabled_pkp_hosts_.end()) { | 1629 end_(state.enabled_pkp_hosts_.end()) { |
| 1628 } | 1630 } |
| 1629 | 1631 |
| 1630 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { | 1632 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { |
| 1631 } | 1633 } |
| 1632 | 1634 |
| 1633 } // namespace | 1635 } // namespace |
| OLD | NEW |