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 #include "chrome/browser/net/ssl_config_service_manager.h" | 4 #include "chrome/browser/net/ssl_config_service_manager.h" |
5 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
20 #include "components/content_settings/core/browser/content_settings_utils.h" | 20 #include "components/content_settings/core/browser/content_settings_utils.h" |
21 #include "components/content_settings/core/common/content_settings.h" | 21 #include "components/content_settings/core/common/content_settings.h" |
22 #include "components/google/core/browser/google_util.h" | |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 #include "net/socket/ssl_client_socket.h" | 24 #include "net/socket/ssl_client_socket.h" |
24 #include "net/ssl/ssl_cipher_suite_names.h" | 25 #include "net/ssl/ssl_cipher_suite_names.h" |
25 #include "net/ssl/ssl_config_service.h" | 26 #include "net/ssl/ssl_config_service.h" |
27 #include "url/gurl.h" | |
26 | 28 |
27 using content::BrowserThread; | 29 using content::BrowserThread; |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
33 // Field trial for ClientHello padding. | |
34 const char kClientHelloFieldTrialName[] = "FastRadioPadding"; | |
35 const char kClientHelloFieldTrialEnabledGroupName[] = "Enabled"; | |
36 | |
31 // Converts a ListValue of StringValues into a vector of strings. Any Values | 37 // Converts a ListValue of StringValues into a vector of strings. Any Values |
32 // which cannot be converted will be skipped. | 38 // which cannot be converted will be skipped. |
33 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { | 39 std::vector<std::string> ListValueToStringVector(const base::ListValue* value) { |
34 std::vector<std::string> results; | 40 std::vector<std::string> results; |
35 results.reserve(value->GetSize()); | 41 results.reserve(value->GetSize()); |
36 std::string s; | 42 std::string s; |
37 for (base::ListValue::const_iterator it = value->begin(); it != value->end(); | 43 for (base::ListValue::const_iterator it = value->begin(); it != value->end(); |
38 ++it) { | 44 ++it) { |
39 if (!(*it)->GetAsString(&s)) | 45 if (!(*it)->GetAsString(&s)) |
40 continue; | 46 continue; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // An SSLConfigService which stores a cached version of the current SSLConfig | 95 // An SSLConfigService which stores a cached version of the current SSLConfig |
90 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs | 96 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs |
91 // change. | 97 // change. |
92 class SSLConfigServicePref : public net::SSLConfigService { | 98 class SSLConfigServicePref : public net::SSLConfigService { |
93 public: | 99 public: |
94 SSLConfigServicePref() {} | 100 SSLConfigServicePref() {} |
95 | 101 |
96 // Store SSL config settings in |config|. Must only be called from IO thread. | 102 // Store SSL config settings in |config|. Must only be called from IO thread. |
97 void GetSSLConfig(net::SSLConfig* config) override; | 103 void GetSSLConfig(net::SSLConfig* config) override; |
98 | 104 |
105 bool SupportsFastradioPadding(const GURL& url) override; | |
106 | |
99 private: | 107 private: |
100 // Allow the pref watcher to update our internal state. | 108 // Allow the pref watcher to update our internal state. |
101 friend class SSLConfigServiceManagerPref; | 109 friend class SSLConfigServiceManagerPref; |
102 | 110 |
103 ~SSLConfigServicePref() override {} | 111 ~SSLConfigServicePref() override {} |
104 | 112 |
105 // This method is posted to the IO thread from the browser thread to carry the | 113 // This method is posted to the IO thread from the browser thread to carry the |
106 // new config information. | 114 // new config information. |
107 void SetNewSSLConfig(const net::SSLConfig& new_config); | 115 void SetNewSSLConfig(const net::SSLConfig& new_config); |
108 | 116 |
109 // Cached value of prefs, should only be accessed from IO thread. | 117 // Cached value of prefs, should only be accessed from IO thread. |
110 net::SSLConfig cached_config_; | 118 net::SSLConfig cached_config_; |
111 | 119 |
112 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); | 120 DISALLOW_COPY_AND_ASSIGN(SSLConfigServicePref); |
113 }; | 121 }; |
114 | 122 |
115 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { | 123 void SSLConfigServicePref::GetSSLConfig(net::SSLConfig* config) { |
116 *config = cached_config_; | 124 *config = cached_config_; |
117 } | 125 } |
118 | 126 |
127 bool SSLConfigServicePref::SupportsFastradioPadding(const GURL& url) { | |
Ryan Sleevi
2015/02/09 19:42:34
Should this be FastRadioPadding? "fastradio" isn't
jeremyim
2015/02/09 21:32:15
The BoringSSL function is SSL_enable_fastradio_pad
| |
128 return google_util::IsGoogleHostname(url.host(), | |
129 google_util::ALLOW_SUBDOMAIN); | |
130 } | |
131 | |
119 void SSLConfigServicePref::SetNewSSLConfig( | 132 void SSLConfigServicePref::SetNewSSLConfig( |
120 const net::SSLConfig& new_config) { | 133 const net::SSLConfig& new_config) { |
121 net::SSLConfig orig_config = cached_config_; | 134 net::SSLConfig orig_config = cached_config_; |
122 cached_config_ = new_config; | 135 cached_config_ = new_config; |
123 ProcessConfigUpdate(orig_config, new_config); | 136 ProcessConfigUpdate(orig_config, new_config); |
124 } | 137 } |
125 | 138 |
126 //////////////////////////////////////////////////////////////////////////////// | 139 //////////////////////////////////////////////////////////////////////////////// |
127 // SSLConfigServiceManagerPref | 140 // SSLConfigServiceManagerPref |
128 | 141 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 if (version_max) { | 292 if (version_max) { |
280 uint16 supported_version_max = config->version_max; | 293 uint16 supported_version_max = config->version_max; |
281 config->version_max = std::min(supported_version_max, version_max); | 294 config->version_max = std::min(supported_version_max, version_max); |
282 } | 295 } |
283 if (version_fallback_min) { | 296 if (version_fallback_min) { |
284 config->version_fallback_min = version_fallback_min; | 297 config->version_fallback_min = version_fallback_min; |
285 } | 298 } |
286 config->disabled_cipher_suites = disabled_cipher_suites_; | 299 config->disabled_cipher_suites = disabled_cipher_suites_; |
287 // disabling False Start also happens to disable record splitting. | 300 // disabling False Start also happens to disable record splitting. |
288 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); | 301 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); |
302 | |
303 base::StringPiece group = | |
304 base::FieldTrialList::FindFullName(kClientHelloFieldTrialName); | |
305 if (group.starts_with(kClientHelloFieldTrialEnabledGroupName)) { | |
Ryan Sleevi
2015/02/09 19:42:34
Why is this .starts_with and not ==?
jeremyim
2015/02/09 21:32:15
In case there is a reason to have multiple "Enable
| |
306 config->fastradio_padding_enabled = true; | |
307 } | |
289 } | 308 } |
290 | 309 |
291 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( | 310 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( |
292 PrefService* local_state) { | 311 PrefService* local_state) { |
293 const base::ListValue* value = | 312 const base::ListValue* value = |
294 local_state->GetList(prefs::kCipherSuiteBlacklist); | 313 local_state->GetList(prefs::kCipherSuiteBlacklist); |
295 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); | 314 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); |
296 } | 315 } |
297 | 316 |
298 //////////////////////////////////////////////////////////////////////////////// | 317 //////////////////////////////////////////////////////////////////////////////// |
299 // SSLConfigServiceManager | 318 // SSLConfigServiceManager |
300 | 319 |
301 // static | 320 // static |
302 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( | 321 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( |
303 PrefService* local_state) { | 322 PrefService* local_state) { |
304 return new SSLConfigServiceManagerPref(local_state); | 323 return new SSLConfigServiceManagerPref(local_state); |
305 } | 324 } |
306 | 325 |
307 // static | 326 // static |
308 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { | 327 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { |
309 SSLConfigServiceManagerPref::RegisterPrefs(registry); | 328 SSLConfigServiceManagerPref::RegisterPrefs(registry); |
310 } | 329 } |
OLD | NEW |