| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace net { | 33 namespace net { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 #include "net/http/transport_security_state_static.h" | 37 #include "net/http/transport_security_state_static.h" |
| 38 | 38 |
| 39 const size_t kMaxHPKPReportCacheEntries = 50; | 39 const size_t kMaxHPKPReportCacheEntries = 50; |
| 40 const int kTimeToRememberHPKPReportsMins = 60; | 40 const int kTimeToRememberHPKPReportsMins = 60; |
| 41 const size_t kReportCacheKeyLength = 16; | 41 const size_t kReportCacheKeyLength = 16; |
| 42 | 42 |
| 43 void RecordUMAForHPKPReportFailure(GURL report_uri, int net_error) { |
| 44 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.PublicKeyPinReportSendingFailure", |
| 45 net_error); |
| 46 } |
| 47 |
| 43 std::string TimeToISO8601(const base::Time& t) { | 48 std::string TimeToISO8601(const base::Time& t) { |
| 44 base::Time::Exploded exploded; | 49 base::Time::Exploded exploded; |
| 45 t.UTCExplode(&exploded); | 50 t.UTCExplode(&exploded); |
| 46 return base::StringPrintf( | 51 return base::StringPrintf( |
| 47 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, | 52 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, |
| 48 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, | 53 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, |
| 49 exploded.millisecond); | 54 exploded.millisecond); |
| 50 } | 55 } |
| 51 | 56 |
| 52 scoped_ptr<base::ListValue> GetPEMEncodedChainAsList( | 57 scoped_ptr<base::ListValue> GetPEMEncodedChainAsList( |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 void TransportSecurityState::SetDelegate( | 687 void TransportSecurityState::SetDelegate( |
| 683 TransportSecurityState::Delegate* delegate) { | 688 TransportSecurityState::Delegate* delegate) { |
| 684 DCHECK(CalledOnValidThread()); | 689 DCHECK(CalledOnValidThread()); |
| 685 delegate_ = delegate; | 690 delegate_ = delegate; |
| 686 } | 691 } |
| 687 | 692 |
| 688 void TransportSecurityState::SetReportSender( | 693 void TransportSecurityState::SetReportSender( |
| 689 TransportSecurityState::ReportSender* report_sender) { | 694 TransportSecurityState::ReportSender* report_sender) { |
| 690 DCHECK(CalledOnValidThread()); | 695 DCHECK(CalledOnValidThread()); |
| 691 report_sender_ = report_sender; | 696 report_sender_ = report_sender; |
| 697 if (report_sender_) |
| 698 report_sender_->SetErrorCallback(base::Bind(RecordUMAForHPKPReportFailure)); |
| 692 } | 699 } |
| 693 | 700 |
| 694 void TransportSecurityState::SetExpectCTReporter( | 701 void TransportSecurityState::SetExpectCTReporter( |
| 695 ExpectCTReporter* expect_ct_reporter) { | 702 ExpectCTReporter* expect_ct_reporter) { |
| 696 DCHECK(CalledOnValidThread()); | 703 DCHECK(CalledOnValidThread()); |
| 697 expect_ct_reporter_ = expect_ct_reporter; | 704 expect_ct_reporter_ = expect_ct_reporter; |
| 698 } | 705 } |
| 699 | 706 |
| 700 void TransportSecurityState::AddHSTSInternal( | 707 void TransportSecurityState::AddHSTSInternal( |
| 701 const std::string& host, | 708 const std::string& host, |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 TransportSecurityState::PKPStateIterator::PKPStateIterator( | 1356 TransportSecurityState::PKPStateIterator::PKPStateIterator( |
| 1350 const TransportSecurityState& state) | 1357 const TransportSecurityState& state) |
| 1351 : iterator_(state.enabled_pkp_hosts_.begin()), | 1358 : iterator_(state.enabled_pkp_hosts_.begin()), |
| 1352 end_(state.enabled_pkp_hosts_.end()) { | 1359 end_(state.enabled_pkp_hosts_.end()) { |
| 1353 } | 1360 } |
| 1354 | 1361 |
| 1355 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { | 1362 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { |
| 1356 } | 1363 } |
| 1357 | 1364 |
| 1358 } // namespace | 1365 } // namespace |
| OLD | NEW |