| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 std::unique_ptr<base::ListValue> GetPEMEncodedChainAsList( | 85 std::unique_ptr<base::ListValue> GetPEMEncodedChainAsList( |
| 86 const net::X509Certificate* cert_chain) { | 86 const net::X509Certificate* cert_chain) { |
| 87 if (!cert_chain) | 87 if (!cert_chain) |
| 88 return base::MakeUnique<base::ListValue>(); | 88 return base::MakeUnique<base::ListValue>(); |
| 89 | 89 |
| 90 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 90 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 91 std::vector<std::string> pem_encoded_chain; | 91 std::vector<std::string> pem_encoded_chain; |
| 92 cert_chain->GetPEMEncodedChain(&pem_encoded_chain); | 92 cert_chain->GetPEMEncodedChain(&pem_encoded_chain); |
| 93 for (const std::string& cert : pem_encoded_chain) | 93 for (const std::string& cert : pem_encoded_chain) |
| 94 result->Append(base::MakeUnique<base::StringValue>(cert)); | 94 result->Append(base::MakeUnique<base::Value>(cert)); |
| 95 | 95 |
| 96 return result; | 96 return result; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool HashReportForCache(const base::DictionaryValue& report, | 99 bool HashReportForCache(const base::DictionaryValue& report, |
| 100 const GURL& report_uri, | 100 const GURL& report_uri, |
| 101 std::string* cache_key) { | 101 std::string* cache_key) { |
| 102 char hashed[crypto::kSHA256Length]; | 102 char hashed[crypto::kSHA256Length]; |
| 103 std::string to_hash; | 103 std::string to_hash; |
| 104 if (!base::JSONWriter::Write(report, &to_hash)) | 104 if (!base::JSONWriter::Write(report, &to_hash)) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 std::string base64_value; | 152 std::string base64_value; |
| 153 base::Base64Encode( | 153 base::Base64Encode( |
| 154 base::StringPiece(reinterpret_cast<const char*>(hash_value.data()), | 154 base::StringPiece(reinterpret_cast<const char*>(hash_value.data()), |
| 155 hash_value.size()), | 155 hash_value.size()), |
| 156 &base64_value); | 156 &base64_value); |
| 157 known_pin += "\"" + base64_value + "\""; | 157 known_pin += "\"" + base64_value + "\""; |
| 158 | 158 |
| 159 known_pin_list->Append( | 159 known_pin_list->Append( |
| 160 std::unique_ptr<base::Value>(new base::StringValue(known_pin))); | 160 std::unique_ptr<base::Value>(new base::Value(known_pin))); |
| 161 } | 161 } |
| 162 | 162 |
| 163 report.Set("known-pins", std::move(known_pin_list)); | 163 report.Set("known-pins", std::move(known_pin_list)); |
| 164 | 164 |
| 165 // For the sent reports cache, do not include the effective expiration | 165 // For the sent reports cache, do not include the effective expiration |
| 166 // date. The expiration date will likely change every time the user | 166 // date. The expiration date will likely change every time the user |
| 167 // visits the site, so it would prevent reports from being effectively | 167 // visits the site, so it would prevent reports from being effectively |
| 168 // deduplicated. | 168 // deduplicated. |
| 169 if (!HashReportForCache(report, pkp_state.report_uri, cache_key)) { | 169 if (!HashReportForCache(report, pkp_state.report_uri, cache_key)) { |
| 170 LOG(ERROR) << "Failed to compute cache key for HPKP violation report."; | 170 LOG(ERROR) << "Failed to compute cache key for HPKP violation report."; |
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 TransportSecurityState::PKPStateIterator::PKPStateIterator( | 1654 TransportSecurityState::PKPStateIterator::PKPStateIterator( |
| 1655 const TransportSecurityState& state) | 1655 const TransportSecurityState& state) |
| 1656 : iterator_(state.enabled_pkp_hosts_.begin()), | 1656 : iterator_(state.enabled_pkp_hosts_.begin()), |
| 1657 end_(state.enabled_pkp_hosts_.end()) { | 1657 end_(state.enabled_pkp_hosts_.end()) { |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { | 1660 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 } // namespace | 1663 } // namespace |
| OLD | NEW |