Commit 150ad40f authored by unsafe@trevp.net's avatar unsafe@trevp.net

Remove "--hsts-hosts" so we don't have to maintain it during upcoming changes...

Remove "--hsts-hosts" so we don't have to maintain it during upcoming changes to the TransportSecurityState data structures and JSON format.

The "--hsts-hosts" feature is likely unused, is redundant with net-internals,  and is dangerous since it fails silently.  Also it exposes the internal JSON format to the user.

BUG=156152
R=rsleevi,palmer

Review URL: https://chromiumcodereview.appspot.com/15711007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202957 0039d316-1c4b-4281-b951-d872f2087c98
parent 5a496e5c
...@@ -204,25 +204,16 @@ bool TransportSecurityPersister::SerializeData(std::string* output) { ...@@ -204,25 +204,16 @@ bool TransportSecurityPersister::SerializeData(std::string* output) {
return true; return true;
} }
bool TransportSecurityPersister::DeserializeFromCommandLine(
const std::string& serialized) {
// Purposefully ignore |dirty| because we do not want to persist entries
// deserialized in this way.
bool dirty;
return Deserialize(serialized, true, &dirty, transport_security_state_);
}
bool TransportSecurityPersister::LoadEntries(const std::string& serialized, bool TransportSecurityPersister::LoadEntries(const std::string& serialized,
bool* dirty) { bool* dirty) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
transport_security_state_->ClearDynamicData(); transport_security_state_->ClearDynamicData();
return Deserialize(serialized, false, dirty, transport_security_state_); return Deserialize(serialized, dirty, transport_security_state_);
} }
// static // static
bool TransportSecurityPersister::Deserialize(const std::string& serialized, bool TransportSecurityPersister::Deserialize(const std::string& serialized,
bool forced,
bool* dirty, bool* dirty,
TransportSecurityState* state) { TransportSecurityState* state) {
scoped_ptr<Value> value(base::JSONReader::Read(serialized)); scoped_ptr<Value> value(base::JSONReader::Read(serialized));
...@@ -307,9 +298,6 @@ bool TransportSecurityPersister::Deserialize(const std::string& serialized, ...@@ -307,9 +298,6 @@ bool TransportSecurityPersister::Deserialize(const std::string& serialized,
continue; continue;
} }
if (forced)
state->AddOrUpdateForcedHosts(hashed, domain_state);
else
state->AddOrUpdateEnabledHosts(hashed, domain_state); state->AddOrUpdateEnabledHosts(hashed, domain_state);
} }
......
...@@ -85,11 +85,6 @@ class TransportSecurityPersister ...@@ -85,11 +85,6 @@ class TransportSecurityPersister
// serialized state on disk. // serialized state on disk.
virtual bool SerializeData(std::string* data) OVERRIDE; virtual bool SerializeData(std::string* data) OVERRIDE;
// Parses an array of JSON-encoded TransportSecurityState::DomainState
// entries. For use in loading entries defined on the command line
// (switches::kHstsHosts).
bool DeserializeFromCommandLine(const std::string& serialized);
// Clears any existing non-static entries, and then re-populates // Clears any existing non-static entries, and then re-populates
// |transport_security_state_|. // |transport_security_state_|.
// //
...@@ -101,14 +96,11 @@ class TransportSecurityPersister ...@@ -101,14 +96,11 @@ class TransportSecurityPersister
class Loader; class Loader;
// Populates |state| from the JSON string |serialized|. Returns true if // Populates |state| from the JSON string |serialized|. Returns true if
// all entries were parsed and deserialized correctly. If |forced| is // all entries were parsed and deserialized correctly.
// true, updates |state|'s map of "forced" DomainState entries; normally,
// leave this false.
// //
// Sets |*dirty| to true if the new state differs from the persisted // Sets |*dirty| to true if the new state differs from the persisted
// state; false otherwise. // state; false otherwise.
static bool Deserialize(const std::string& serialized, static bool Deserialize(const std::string& serialized,
bool forced,
bool* dirty, bool* dirty,
net::TransportSecurityState* state); net::TransportSecurityState* state);
......
...@@ -210,25 +210,3 @@ TEST_F(TransportSecurityPersisterTest, PublicKeyHashes) { ...@@ -210,25 +210,3 @@ TEST_F(TransportSecurityPersisterTest, PublicKeyHashes) {
EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(), EXPECT_EQ(0, memcmp(domain_state.dynamic_spki_hashes[0].data(), sha1.data(),
sha1.size())); sha1.size()));
} }
TEST_F(TransportSecurityPersisterTest, ForcePreloads) {
// The static state for docs.google.com, defined in
// net/http/transport_security_state_static.h, has pins and mode strict.
// This new policy overrides that with no pins and a weaker mode. We apply
// this new policy with |DeserializeFromCommandLine| and expect that the
// new policy is in effect, overriding the static policy.
std::string preload("{"
"\"4AGT3lHihuMSd5rUj7B4u6At0jlSH3HFePovjPR+oLE=\": {"
"\"created\": 0.0,"
"\"expiry\": 2000000000.0,"
"\"include_subdomains\": false,"
"\"mode\": \"pinning-only\""
"}}");
EXPECT_TRUE(persister_->DeserializeFromCommandLine(preload));
TransportSecurityState::DomainState domain_state;
EXPECT_TRUE(state_.GetDomainState("docs.google.com", true, &domain_state));
EXPECT_FALSE(domain_state.HasPublicKeyPins());
EXPECT_FALSE(domain_state.ShouldUpgradeToSSL());
}
...@@ -688,9 +688,6 @@ void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const { ...@@ -688,9 +688,6 @@ void ProfileIOData::Init(content::ProtocolHandlerMap* protocol_handlers) const {
new TransportSecurityPersister(transport_security_state_.get(), new TransportSecurityPersister(transport_security_state_.get(),
profile_params_->path, profile_params_->path,
is_incognito())); is_incognito()));
const std::string& serialized =
command_line.GetSwitchValueASCII(switches::kHstsHosts);
transport_security_persister_.get()->DeserializeFromCommandLine(serialized);
// Take ownership over these parameters. // Take ownership over these parameters.
cookie_settings_ = profile_params_->cookie_settings; cookie_settings_ = profile_params_->cookie_settings;
......
...@@ -817,12 +817,6 @@ const char kHostResolverParallelism[] = "host-resolver-parallelism"; ...@@ -817,12 +817,6 @@ const char kHostResolverParallelism[] = "host-resolver-parallelism";
// to disable host resolver retry attempts. // to disable host resolver retry attempts.
const char kHostResolverRetryAttempts[] = "host-resolver-retry-attempts"; const char kHostResolverRetryAttempts[] = "host-resolver-retry-attempts";
// Takes the JSON-formatted HSTS specification and loads it as if it were a
// preloaded HSTS entry. Takes precedence over both website-specified rules and
// built-in rules. The JSON format is the same as that persisted in
// <profile_dir>/Default/TransportSecurity
const char kHstsHosts[] = "hsts-hosts";
// Causes net::URLFetchers to ignore requests for SSL client certificates, // Causes net::URLFetchers to ignore requests for SSL client certificates,
// causing them to attempt an unauthenticated SSL/TLS session. This is intended // causing them to attempt an unauthenticated SSL/TLS session. This is intended
// for use when testing various service URLs (eg: kPromoServerURL, kInstantURL, // for use when testing various service URLs (eg: kPromoServerURL, kInstantURL,
......
...@@ -225,7 +225,6 @@ extern const char kHomePage[]; ...@@ -225,7 +225,6 @@ extern const char kHomePage[];
extern const char kHostRules[]; extern const char kHostRules[];
extern const char kHostResolverParallelism[]; extern const char kHostResolverParallelism[];
extern const char kHostResolverRetryAttempts[]; extern const char kHostResolverRetryAttempts[];
extern const char kHstsHosts[];
extern const char kIgnoreUrlFetcherCertRequests[]; extern const char kIgnoreUrlFetcherCertRequests[];
extern const char kIncognito[]; extern const char kIncognito[];
extern const char kInstallFromWebstore[]; extern const char kInstallFromWebstore[];
......
...@@ -756,12 +756,6 @@ bool TransportSecurityState::GetStaticDomainState( ...@@ -756,12 +756,6 @@ bool TransportSecurityState::GetStaticDomainState(
std::string host_sub_chunk(&canonicalized_host[i], std::string host_sub_chunk(&canonicalized_host[i],
canonicalized_host.size() - i); canonicalized_host.size() - i);
out->domain = DNSDomainToString(host_sub_chunk); out->domain = DNSDomainToString(host_sub_chunk);
std::string hashed_host(HashHost(host_sub_chunk));
if (forced_hosts_.find(hashed_host) != forced_hosts_.end()) {
*out = forced_hosts_[hashed_host];
out->domain = DNSDomainToString(host_sub_chunk);
return true;
}
bool ret; bool ret;
if (is_build_timely && if (is_build_timely &&
HasPreload(kPreloadedSTS, kNumPreloadedSTS, canonicalized_host, i, out, HasPreload(kPreloadedSTS, kNumPreloadedSTS, canonicalized_host, i, out,
...@@ -784,11 +778,6 @@ void TransportSecurityState::AddOrUpdateEnabledHosts( ...@@ -784,11 +778,6 @@ void TransportSecurityState::AddOrUpdateEnabledHosts(
enabled_hosts_[hashed_host] = state; enabled_hosts_[hashed_host] = state;
} }
void TransportSecurityState::AddOrUpdateForcedHosts(
const std::string& hashed_host, const DomainState& state) {
forced_hosts_[hashed_host] = state;
}
TransportSecurityState::DomainState::DomainState() TransportSecurityState::DomainState::DomainState()
: upgrade_mode(MODE_FORCE_HTTPS), : upgrade_mode(MODE_FORCE_HTTPS),
created(base::Time::Now()), created(base::Time::Now()),
......
...@@ -179,14 +179,6 @@ class NET_EXPORT TransportSecurityState ...@@ -179,14 +179,6 @@ class NET_EXPORT TransportSecurityState
void AddOrUpdateEnabledHosts(const std::string& hashed_host, void AddOrUpdateEnabledHosts(const std::string& hashed_host,
const DomainState& state); const DomainState& state);
// Inserts |state| into |forced_hosts_| under the key |hashed_host|.
// |hashed_host| is already in the internal representation
// HashHost(CanonicalizeHost(host)).
// Note: This is only used for serializing/deserializing the
// TransportSecurityState.
void AddOrUpdateForcedHosts(const std::string& hashed_host,
const DomainState& state);
// Deletes all dynamic data (e.g. HSTS or HPKP data) created since a given // Deletes all dynamic data (e.g. HSTS or HPKP data) created since a given
// time. // time.
// //
...@@ -310,10 +302,6 @@ class NET_EXPORT TransportSecurityState ...@@ -310,10 +302,6 @@ class NET_EXPORT TransportSecurityState
// The set of hosts that have enabled TransportSecurity. // The set of hosts that have enabled TransportSecurity.
DomainStateMap enabled_hosts_; DomainStateMap enabled_hosts_;
// Extra entries, provided by the user at run-time, to treat as if they
// were static.
DomainStateMap forced_hosts_;
Delegate* delegate_; Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); DISALLOW_COPY_AND_ASSIGN(TransportSecurityState);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment