Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: chrome/browser/net/ssl_config_service_manager_pref.cc

Issue 14125003: Do not roll back to SSL 3.0 for Google properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 LOG(ERROR) << "Ignoring unrecognized or unparsable cipher suite: " 55 LOG(ERROR) << "Ignoring unrecognized or unparsable cipher suite: "
56 << *it; 56 << *it;
57 continue; 57 continue;
58 } 58 }
59 cipher_suites.push_back(cipher_suite); 59 cipher_suites.push_back(cipher_suite);
60 } 60 }
61 std::sort(cipher_suites.begin(), cipher_suites.end()); 61 std::sort(cipher_suites.begin(), cipher_suites.end());
62 return cipher_suites; 62 return cipher_suites;
63 } 63 }
64 64
65 // Returns the string representation of an SSL protocol version. Returns an
66 // empty string on error.
67 std::string SSLProtocolVersionToString(uint16 version) {
68 switch (version) {
69 case net::SSL_PROTOCOL_VERSION_SSL3:
70 return "ssl3";
71 case net::SSL_PROTOCOL_VERSION_TLS1:
72 return "tls1";
73 case net::SSL_PROTOCOL_VERSION_TLS1_1:
74 return "tls1.1";
75 case net::SSL_PROTOCOL_VERSION_TLS1_2:
76 return "tls1.2";
77 default:
78 NOTREACHED();
79 return std::string();
80 }
81 }
82
83 // Returns the SSL protocol version (as a uint16) represented by a string.
84 // Returns 0 if the string is invalid.
85 uint16 SSLProtocolVersionFromString(const std::string& version_str) {
86 uint16 version = 0; // Invalid.
87 if (version_str == "ssl3") {
88 version = net::SSL_PROTOCOL_VERSION_SSL3;
89 } else if (version_str == "tls1") {
90 version = net::SSL_PROTOCOL_VERSION_TLS1;
91 } else if (version_str == "tls1.1") {
92 version = net::SSL_PROTOCOL_VERSION_TLS1_1;
93 } else if (version_str == "tls1.2") {
94 version = net::SSL_PROTOCOL_VERSION_TLS1_2;
95 }
96 return version;
97 }
98
99 } // namespace 65 } // namespace
100 66
101 //////////////////////////////////////////////////////////////////////////////// 67 ////////////////////////////////////////////////////////////////////////////////
102 // SSLConfigServicePref 68 // SSLConfigServicePref
103 69
104 // An SSLConfigService which stores a cached version of the current SSLConfig 70 // An SSLConfigService which stores a cached version of the current SSLConfig
105 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs 71 // prefs, which are updated by SSLConfigServiceManagerPref when the prefs
106 // change. 72 // change.
107 class SSLConfigServicePref : public net::SSLConfigService { 73 class SSLConfigServicePref : public net::SSLConfigService {
108 public: 74 public:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 139
174 PrefChangeRegistrar local_state_change_registrar_; 140 PrefChangeRegistrar local_state_change_registrar_;
175 PrefChangeRegistrar user_prefs_change_registrar_; 141 PrefChangeRegistrar user_prefs_change_registrar_;
176 142
177 // The local_state prefs (should only be accessed from UI thread) 143 // The local_state prefs (should only be accessed from UI thread)
178 BooleanPrefMember rev_checking_enabled_; 144 BooleanPrefMember rev_checking_enabled_;
179 StringPrefMember ssl_version_min_; 145 StringPrefMember ssl_version_min_;
180 StringPrefMember ssl_version_max_; 146 StringPrefMember ssl_version_max_;
181 BooleanPrefMember channel_id_enabled_; 147 BooleanPrefMember channel_id_enabled_;
182 BooleanPrefMember ssl_record_splitting_disabled_; 148 BooleanPrefMember ssl_record_splitting_disabled_;
149 BooleanPrefMember ssl_version_min_preloaded_disabled_;
183 150
184 // The cached list of disabled SSL cipher suites. 151 // The cached list of disabled SSL cipher suites.
185 std::vector<uint16> disabled_cipher_suites_; 152 std::vector<uint16> disabled_cipher_suites_;
186 153
187 // The user_prefs prefs (should only be accessed from UI thread). 154 // The user_prefs prefs (should only be accessed from UI thread).
188 // |have_user_prefs_| will be false if no user_prefs are associated with this 155 // |have_user_prefs_| will be false if no user_prefs are associated with this
189 // instance. 156 // instance.
190 bool have_user_prefs_; 157 bool have_user_prefs_;
191 BooleanPrefMember block_third_party_cookies_; 158 BooleanPrefMember block_third_party_cookies_;
192 159
(...skipping 19 matching lines...) Expand all
212 rev_checking_enabled_.Init( 179 rev_checking_enabled_.Init(
213 prefs::kCertRevocationCheckingEnabled, local_state, local_state_callback); 180 prefs::kCertRevocationCheckingEnabled, local_state, local_state_callback);
214 ssl_version_min_.Init( 181 ssl_version_min_.Init(
215 prefs::kSSLVersionMin, local_state, local_state_callback); 182 prefs::kSSLVersionMin, local_state, local_state_callback);
216 ssl_version_max_.Init( 183 ssl_version_max_.Init(
217 prefs::kSSLVersionMax, local_state, local_state_callback); 184 prefs::kSSLVersionMax, local_state, local_state_callback);
218 channel_id_enabled_.Init( 185 channel_id_enabled_.Init(
219 prefs::kEnableOriginBoundCerts, local_state, local_state_callback); 186 prefs::kEnableOriginBoundCerts, local_state, local_state_callback);
220 ssl_record_splitting_disabled_.Init( 187 ssl_record_splitting_disabled_.Init(
221 prefs::kDisableSSLRecordSplitting, local_state, local_state_callback); 188 prefs::kDisableSSLRecordSplitting, local_state, local_state_callback);
189 ssl_version_min_preloaded_disabled_.Init(
190 prefs::kDisableSSLVersionMinPreloaded, local_state, local_state_callback);
222 191
223 local_state_change_registrar_.Init(local_state); 192 local_state_change_registrar_.Init(local_state);
224 local_state_change_registrar_.Add( 193 local_state_change_registrar_.Add(
225 prefs::kCipherSuiteBlacklist, local_state_callback); 194 prefs::kCipherSuiteBlacklist, local_state_callback);
226 195
227 OnDisabledCipherSuitesChange(local_state); 196 OnDisabledCipherSuitesChange(local_state);
228 197
229 if (user_prefs) { 198 if (user_prefs) {
230 PrefChangeRegistrar::NamedChangeCallback user_prefs_callback = base::Bind( 199 PrefChangeRegistrar::NamedChangeCallback user_prefs_callback = base::Bind(
231 &SSLConfigServiceManagerPref::OnPreferenceChanged, 200 &SSLConfigServiceManagerPref::OnPreferenceChanged,
(...skipping 12 matching lines...) Expand all
244 // the IO thread trying to access it yet. 213 // the IO thread trying to access it yet.
245 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_); 214 GetSSLConfigFromPrefs(&ssl_config_service_->cached_config_);
246 } 215 }
247 216
248 // static 217 // static
249 void SSLConfigServiceManagerPref::RegisterPrefs(PrefRegistrySimple* registry) { 218 void SSLConfigServiceManagerPref::RegisterPrefs(PrefRegistrySimple* registry) {
250 net::SSLConfig default_config; 219 net::SSLConfig default_config;
251 registry->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled, 220 registry->RegisterBooleanPref(prefs::kCertRevocationCheckingEnabled,
252 default_config.rev_checking_enabled); 221 default_config.rev_checking_enabled);
253 std::string version_min_str = 222 std::string version_min_str =
254 SSLProtocolVersionToString(default_config.version_min); 223 net::SSLConfig::SSLProtocolVersionToString(default_config.version_min);
255 std::string version_max_str = 224 std::string version_max_str =
256 SSLProtocolVersionToString(default_config.version_max); 225 net::SSLConfig::SSLProtocolVersionToString(default_config.version_max);
257 registry->RegisterStringPref(prefs::kSSLVersionMin, version_min_str); 226 registry->RegisterStringPref(prefs::kSSLVersionMin, version_min_str);
258 registry->RegisterStringPref(prefs::kSSLVersionMax, version_max_str); 227 registry->RegisterStringPref(prefs::kSSLVersionMax, version_max_str);
259 registry->RegisterBooleanPref(prefs::kEnableOriginBoundCerts, 228 registry->RegisterBooleanPref(prefs::kEnableOriginBoundCerts,
260 default_config.channel_id_enabled); 229 default_config.channel_id_enabled);
261 registry->RegisterBooleanPref(prefs::kDisableSSLRecordSplitting, 230 registry->RegisterBooleanPref(prefs::kDisableSSLRecordSplitting,
262 !default_config.false_start_enabled); 231 !default_config.false_start_enabled);
232 registry->RegisterBooleanPref(
233 prefs::kDisableSSLVersionMinPreloaded,
234 default_config.ssl_version_min_preloaded_disabled);
263 registry->RegisterListPref(prefs::kCipherSuiteBlacklist); 235 registry->RegisterListPref(prefs::kCipherSuiteBlacklist);
264 } 236 }
265 237
266 net::SSLConfigService* SSLConfigServiceManagerPref::Get() { 238 net::SSLConfigService* SSLConfigServiceManagerPref::Get() {
267 return ssl_config_service_; 239 return ssl_config_service_;
268 } 240 }
269 241
270 void SSLConfigServiceManagerPref::OnPreferenceChanged( 242 void SSLConfigServiceManagerPref::OnPreferenceChanged(
271 PrefService* prefs, 243 PrefService* prefs,
272 const std::string& pref_name_in) { 244 const std::string& pref_name_in) {
(...skipping 18 matching lines...) Expand all
291 new_config)); 263 new_config));
292 } 264 }
293 265
294 void SSLConfigServiceManagerPref::GetSSLConfigFromPrefs( 266 void SSLConfigServiceManagerPref::GetSSLConfigFromPrefs(
295 net::SSLConfig* config) { 267 net::SSLConfig* config) {
296 config->rev_checking_enabled = rev_checking_enabled_.GetValue(); 268 config->rev_checking_enabled = rev_checking_enabled_.GetValue();
297 std::string version_min_str = ssl_version_min_.GetValue(); 269 std::string version_min_str = ssl_version_min_.GetValue();
298 std::string version_max_str = ssl_version_max_.GetValue(); 270 std::string version_max_str = ssl_version_max_.GetValue();
299 config->version_min = net::SSLConfigService::default_version_min(); 271 config->version_min = net::SSLConfigService::default_version_min();
300 config->version_max = net::SSLConfigService::default_version_max(); 272 config->version_max = net::SSLConfigService::default_version_max();
301 uint16 version_min = SSLProtocolVersionFromString(version_min_str); 273 uint16 version_min = net::SSLConfig::SSLProtocolVersionFromString(
302 uint16 version_max = SSLProtocolVersionFromString(version_max_str); 274 version_min_str);
275 uint16 version_max = net::SSLConfig::SSLProtocolVersionFromString(
276 version_max_str);
303 if (version_min) { 277 if (version_min) {
304 // TODO(wtc): get the minimum SSL protocol version supported by the 278 // TODO(wtc): get the minimum SSL protocol version supported by the
305 // SSLClientSocket class. Right now it happens to be the same as the 279 // SSLClientSocket class. Right now it happens to be the same as the
306 // default minimum SSL protocol version because we enable all supported 280 // default minimum SSL protocol version because we enable all supported
307 // versions by default. 281 // versions by default.
308 uint16 supported_version_min = config->version_min; 282 uint16 supported_version_min = config->version_min;
309 config->version_min = std::max(supported_version_min, version_min); 283 config->version_min = std::max(supported_version_min, version_min);
310 } 284 }
311 if (version_max) { 285 if (version_max) {
312 // TODO(wtc): get the maximum SSL protocol version supported by the 286 // TODO(wtc): get the maximum SSL protocol version supported by the
313 // SSLClientSocket class. 287 // SSLClientSocket class.
314 uint16 supported_version_max = config->version_max; 288 uint16 supported_version_max = config->version_max;
315 config->version_max = std::min(supported_version_max, version_max); 289 config->version_max = std::min(supported_version_max, version_max);
316 } 290 }
317 config->disabled_cipher_suites = disabled_cipher_suites_; 291 config->disabled_cipher_suites = disabled_cipher_suites_;
318 config->channel_id_enabled = channel_id_enabled_.GetValue(); 292 config->channel_id_enabled = channel_id_enabled_.GetValue();
319 if (have_user_prefs_ && 293 if (have_user_prefs_ &&
320 (cookies_disabled_ || block_third_party_cookies_.GetValue())) 294 (cookies_disabled_ || block_third_party_cookies_.GetValue()))
321 config->channel_id_enabled = false; 295 config->channel_id_enabled = false;
322 // disabling False Start also happens to disable record splitting. 296 // disabling False Start also happens to disable record splitting.
323 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue(); 297 config->false_start_enabled = !ssl_record_splitting_disabled_.GetValue();
298 config->ssl_version_min_preloaded_disabled =
299 ssl_version_min_preloaded_disabled_.GetValue();
324 SSLConfigServicePref::SetSSLConfigFlags(config); 300 SSLConfigServicePref::SetSSLConfigFlags(config);
325 } 301 }
326 302
327 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange( 303 void SSLConfigServiceManagerPref::OnDisabledCipherSuitesChange(
328 PrefService* local_state) { 304 PrefService* local_state) {
329 const ListValue* value = local_state->GetList(prefs::kCipherSuiteBlacklist); 305 const ListValue* value = local_state->GetList(prefs::kCipherSuiteBlacklist);
330 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value)); 306 disabled_cipher_suites_ = ParseCipherSuites(ListValueToStringVector(value));
331 } 307 }
332 308
333 void SSLConfigServiceManagerPref::OnDefaultContentSettingsChange( 309 void SSLConfigServiceManagerPref::OnDefaultContentSettingsChange(
(...skipping 15 matching lines...) Expand all
349 // static 325 // static
350 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager( 326 SSLConfigServiceManager* SSLConfigServiceManager::CreateDefaultManager(
351 PrefService* local_state, PrefService* user_prefs) { 327 PrefService* local_state, PrefService* user_prefs) {
352 return new SSLConfigServiceManagerPref(local_state, user_prefs); 328 return new SSLConfigServiceManagerPref(local_state, user_prefs);
353 } 329 }
354 330
355 // static 331 // static
356 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) { 332 void SSLConfigServiceManager::RegisterPrefs(PrefRegistrySimple* registry) {
357 SSLConfigServiceManagerPref::RegisterPrefs(registry); 333 SSLConfigServiceManagerPref::RegisterPrefs(registry);
358 } 334 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/ssl_config_service_manager_pref_unittest.cc » ('j') | chrome/common/chrome_switches.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698