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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 | 749 |
750 out->upgrade_mode = DomainState::MODE_FORCE_HTTPS; | 750 out->upgrade_mode = DomainState::MODE_FORCE_HTTPS; |
751 out->include_subdomains = false; | 751 out->include_subdomains = false; |
752 | 752 |
753 const bool is_build_timely = IsBuildTimely(); | 753 const bool is_build_timely = IsBuildTimely(); |
754 | 754 |
755 for (size_t i = 0; canonicalized_host[i]; i += canonicalized_host[i] + 1) { | 755 for (size_t i = 0; canonicalized_host[i]; i += canonicalized_host[i] + 1) { |
756 std::string host_sub_chunk(&canonicalized_host[i], | 756 std::string host_sub_chunk(&canonicalized_host[i], |
757 canonicalized_host.size() - i); | 757 canonicalized_host.size() - i); |
758 out->domain = DNSDomainToString(host_sub_chunk); | 758 out->domain = DNSDomainToString(host_sub_chunk); |
759 std::string hashed_host(HashHost(host_sub_chunk)); | |
760 if (forced_hosts_.find(hashed_host) != forced_hosts_.end()) { | |
761 *out = forced_hosts_[hashed_host]; | |
762 out->domain = DNSDomainToString(host_sub_chunk); | |
763 return true; | |
764 } | |
765 bool ret; | 759 bool ret; |
766 if (is_build_timely && | 760 if (is_build_timely && |
767 HasPreload(kPreloadedSTS, kNumPreloadedSTS, canonicalized_host, i, out, | 761 HasPreload(kPreloadedSTS, kNumPreloadedSTS, canonicalized_host, i, out, |
768 &ret)) { | 762 &ret)) { |
769 return ret; | 763 return ret; |
770 } | 764 } |
771 if (sni_enabled && | 765 if (sni_enabled && |
772 is_build_timely && | 766 is_build_timely && |
773 HasPreload(kPreloadedSNISTS, kNumPreloadedSNISTS, canonicalized_host, i, | 767 HasPreload(kPreloadedSNISTS, kNumPreloadedSNISTS, canonicalized_host, i, |
774 out, &ret)) { | 768 out, &ret)) { |
775 return ret; | 769 return ret; |
776 } | 770 } |
777 } | 771 } |
778 | 772 |
779 return false; | 773 return false; |
780 } | 774 } |
781 | 775 |
782 void TransportSecurityState::AddOrUpdateEnabledHosts( | 776 void TransportSecurityState::AddOrUpdateEnabledHosts( |
783 const std::string& hashed_host, const DomainState& state) { | 777 const std::string& hashed_host, const DomainState& state) { |
784 enabled_hosts_[hashed_host] = state; | 778 enabled_hosts_[hashed_host] = state; |
785 } | 779 } |
786 | 780 |
787 void TransportSecurityState::AddOrUpdateForcedHosts( | |
788 const std::string& hashed_host, const DomainState& state) { | |
789 forced_hosts_[hashed_host] = state; | |
790 } | |
791 | |
792 TransportSecurityState::DomainState::DomainState() | 781 TransportSecurityState::DomainState::DomainState() |
793 : upgrade_mode(MODE_FORCE_HTTPS), | 782 : upgrade_mode(MODE_FORCE_HTTPS), |
794 created(base::Time::Now()), | 783 created(base::Time::Now()), |
795 include_subdomains(false) { | 784 include_subdomains(false) { |
796 } | 785 } |
797 | 786 |
798 TransportSecurityState::DomainState::~DomainState() { | 787 TransportSecurityState::DomainState::~DomainState() { |
799 } | 788 } |
800 | 789 |
801 bool TransportSecurityState::DomainState::CheckPublicKeyPins( | 790 bool TransportSecurityState::DomainState::CheckPublicKeyPins( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 return true; | 837 return true; |
849 } | 838 } |
850 | 839 |
851 bool TransportSecurityState::DomainState::HasPublicKeyPins() const { | 840 bool TransportSecurityState::DomainState::HasPublicKeyPins() const { |
852 return static_spki_hashes.size() > 0 || | 841 return static_spki_hashes.size() > 0 || |
853 bad_static_spki_hashes.size() > 0 || | 842 bad_static_spki_hashes.size() > 0 || |
854 dynamic_spki_hashes.size() > 0; | 843 dynamic_spki_hashes.size() > 0; |
855 } | 844 } |
856 | 845 |
857 } // namespace | 846 } // namespace |
OLD | NEW |