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 #if defined(USE_OPENSSL) | 7 #if defined(USE_OPENSSL) |
8 #include <openssl/ecdsa.h> | 8 #include <openssl/ecdsa.h> |
9 #include <openssl/ssl.h> | 9 #include <openssl/ssl.h> |
10 #else // !defined(USE_OPENSSL) | 10 #else // !defined(USE_OPENSSL) |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 if (max_age.InSeconds() == 0) | 659 if (max_age.InSeconds() == 0) |
660 domain_state.pkp.spki_hashes.clear(); | 660 domain_state.pkp.spki_hashes.clear(); |
661 domain_state.pkp.last_observed = now; | 661 domain_state.pkp.last_observed = now; |
662 domain_state.pkp.expiry = now + max_age; | 662 domain_state.pkp.expiry = now + max_age; |
663 EnableHost(host, domain_state); | 663 EnableHost(host, domain_state); |
664 return true; | 664 return true; |
665 } | 665 } |
666 return false; | 666 return false; |
667 } | 667 } |
668 | 668 |
669 bool TransportSecurityState::VerifyPinning( | |
670 const HashValueVector& public_key_hashes, | |
671 bool is_issued_by_known_root, | |
672 bool sni_available, | |
673 const std::string& host, | |
674 std::string* pinning_failure_log) { | |
675 #if defined(OFFICIAL_BUILD) && !defined(OS_ANDROID) && !defined(OS_IOS) | |
agl
2014/08/07 18:32:59
Now that this is it's own function, I think this w
Ryan Hamilton
2014/08/07 18:44:26
Done. (Though I used "#else" instead of #endif bec
| |
676 // Take care of any mandates for public key pinning. | |
677 // | |
678 // Pinning is only enabled for official builds to make sure that others don't | |
679 // end up with pins that cannot be easily updated. | |
680 // | |
681 // TODO(agl): We might have an issue here where a request for foo.example.com | |
682 // merges into a SPDY connection to www.example.com, and gets a different | |
683 // certificate. | |
684 | |
685 // Perform pin validation if, and only if, all these conditions obtain: | |
686 // | |
687 // * a TransportSecurityState object is available; | |
688 // * the server's certificate chain is valid (or suffers from only a minor | |
689 // error); | |
690 // * the server's certificate chain chains up to a known root (i.e. not a | |
691 // user-installed trust anchor); and | |
692 // * the build is recent (very old builds should fail open so that users | |
693 // have some chance to recover). | |
694 // | |
695 if (!is_issued_by_known_root || !TransportSecurityState::IsBuildTimely()) { | |
696 return true; | |
697 } | |
agl
2014/08/07 18:32:59
if (!is_issued_by_known_root ||
!TransportSecu
Ryan Hamilton
2014/08/07 18:44:26
Done.
| |
698 | |
699 if (!HasPublicKeyPins(host, sni_available)) | |
700 return true; | |
701 | |
702 if (CheckPublicKeyPins(host, | |
palmer
2014/08/07 18:50:50
Does it make sense to just move the logic in this
Ryan Hamilton
2014/08/07 20:09:38
Hm. I'm totally happy to do this and it seems like
Ryan Sleevi
2014/08/07 20:40:17
How so / what tests? Our tests don't have OFFICIAL
Ryan Hamilton
2014/08/07 22:07:11
Discussed offline. I *think* I've done what you pr
| |
703 sni_available, | |
704 public_key_hashes, | |
705 pinning_failure_log)) { | |
706 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", true); | |
707 return true; | |
708 } | |
709 | |
710 LOG(ERROR) << *pinning_failure_log; | |
711 UMA_HISTOGRAM_BOOLEAN("Net.PublicKeyPinSuccess", false); | |
712 TransportSecurityState::ReportUMAOnPinFailure(host); | |
713 #else | |
714 return true; | |
715 #endif | |
716 } | |
717 | |
669 bool TransportSecurityState::AddHSTS(const std::string& host, | 718 bool TransportSecurityState::AddHSTS(const std::string& host, |
670 const base::Time& expiry, | 719 const base::Time& expiry, |
671 bool include_subdomains) { | 720 bool include_subdomains) { |
672 DCHECK(CalledOnValidThread()); | 721 DCHECK(CalledOnValidThread()); |
673 | 722 |
674 // Copy-and-modify the existing DomainState for this host (if any). | 723 // Copy-and-modify the existing DomainState for this host (if any). |
675 TransportSecurityState::DomainState domain_state; | 724 TransportSecurityState::DomainState domain_state; |
676 const std::string canonicalized_host = CanonicalizeHost(host); | 725 const std::string canonicalized_host = CanonicalizeHost(host); |
677 const std::string hashed_host = HashHost(canonicalized_host); | 726 const std::string hashed_host = HashHost(canonicalized_host); |
678 DomainStateMap::const_iterator i = enabled_hosts_.find( | 727 DomainStateMap::const_iterator i = enabled_hosts_.find( |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 return pkp.spki_hashes.size() > 0 || pkp.bad_spki_hashes.size() > 0; | 950 return pkp.spki_hashes.size() > 0 || pkp.bad_spki_hashes.size() > 0; |
902 } | 951 } |
903 | 952 |
904 TransportSecurityState::DomainState::PKPState::PKPState() { | 953 TransportSecurityState::DomainState::PKPState::PKPState() { |
905 } | 954 } |
906 | 955 |
907 TransportSecurityState::DomainState::PKPState::~PKPState() { | 956 TransportSecurityState::DomainState::PKPState::~PKPState() { |
908 } | 957 } |
909 | 958 |
910 } // namespace | 959 } // namespace |
OLD | NEW |