| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/ssl_config_service_win.h" | 5 #include "net/base/ssl_config_service_win.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_restrictions.h" | 7 #include "base/threading/thread_restrictions.h" |
| 8 #include "base/win/registry.h" | 8 #include "base/win/registry.h" |
| 9 | 9 |
| 10 using base::TimeDelta; | 10 using base::TimeDelta; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 UpdateConfig(now); | 56 UpdateConfig(now); |
| 57 *config = config_info_; | 57 *config = config_info_; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // static | 60 // static |
| 61 bool SSLConfigServiceWin::GetSSLConfigNow(SSLConfig* config) { | 61 bool SSLConfigServiceWin::GetSSLConfigNow(SSLConfig* config) { |
| 62 // This registry access goes to disk and will slow down the IO thread. | 62 // This registry access goes to disk and will slow down the IO thread. |
| 63 // http://crbug.com/61455 | 63 // http://crbug.com/61455 |
| 64 base::ThreadRestrictions::ScopedAllowIO allow_io; | 64 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 65 RegKey internet_settings; | 65 RegKey internet_settings; |
| 66 if (!internet_settings.Open(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, | 66 if (internet_settings.Open(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, |
| 67 KEY_READ)) | 67 KEY_READ) != ERROR_SUCCESS) |
| 68 return false; | 68 return false; |
| 69 | 69 |
| 70 DWORD revocation; | 70 DWORD revocation = REVOCATION_DEFAULT; |
| 71 if (!internet_settings.ReadValueDW(kRevocationValueName, &revocation)) | 71 internet_settings.ReadValueDW(kRevocationValueName, &revocation); |
| 72 revocation = REVOCATION_DEFAULT; | |
| 73 | 72 |
| 74 DWORD protocols; | 73 DWORD protocols = PROTOCOLS_DEFAULT; |
| 75 if (!internet_settings.ReadValueDW(kProtocolsValueName, &protocols)) | 74 internet_settings.ReadValueDW(kProtocolsValueName, &protocols); |
| 76 protocols = PROTOCOLS_DEFAULT; | |
| 77 | 75 |
| 78 config->rev_checking_enabled = (revocation != 0); | 76 config->rev_checking_enabled = (revocation != 0); |
| 79 config->ssl3_enabled = ((protocols & SSL3) != 0); | 77 config->ssl3_enabled = ((protocols & SSL3) != 0); |
| 80 config->tls1_enabled = ((protocols & TLS1) != 0); | 78 config->tls1_enabled = ((protocols & TLS1) != 0); |
| 81 SSLConfigService::SetSSLConfigFlags(config); | 79 SSLConfigService::SetSSLConfigFlags(config); |
| 82 | 80 |
| 83 // TODO(rsleevi): Possibly respect the registry keys defined in | 81 // TODO(rsleevi): Possibly respect the registry keys defined in |
| 84 // http://support.microsoft.com/kb/245030 (pre-Vista) or | 82 // http://support.microsoft.com/kb/245030 (pre-Vista) or |
| 85 // http://msdn.microsoft.com/en-us/library/bb870930(VS.85).aspx (post-Vista). | 83 // http://msdn.microsoft.com/en-us/library/bb870930(VS.85).aspx (post-Vista). |
| 86 // Currently, these values are respected implicitly when using | 84 // Currently, these values are respected implicitly when using |
| (...skipping 26 matching lines...) Expand all Loading... |
| 113 SetSSLVersionEnabled(TLS1, enabled); | 111 SetSSLVersionEnabled(TLS1, enabled); |
| 114 } | 112 } |
| 115 | 113 |
| 116 // static | 114 // static |
| 117 void SSLConfigServiceWin::SetSSLVersionEnabled(int version, bool enabled) { | 115 void SSLConfigServiceWin::SetSSLVersionEnabled(int version, bool enabled) { |
| 118 // This registry access goes to disk and will slow down the IO thread. | 116 // This registry access goes to disk and will slow down the IO thread. |
| 119 // http://crbug.com/61455 | 117 // http://crbug.com/61455 |
| 120 base::ThreadRestrictions::ScopedAllowIO allow_io; | 118 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 121 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, | 119 RegKey internet_settings(HKEY_CURRENT_USER, kInternetSettingsSubKeyName, |
| 122 KEY_READ | KEY_WRITE); | 120 KEY_READ | KEY_WRITE); |
| 123 DWORD value; | 121 DWORD value = PROTOCOLS_DEFAULT; |
| 124 if (!internet_settings.ReadValueDW(kProtocolsValueName, &value)) | 122 internet_settings.ReadValueDW(kProtocolsValueName, &value); |
| 125 value = PROTOCOLS_DEFAULT; | 123 |
| 126 if (enabled) | 124 if (enabled) |
| 127 value |= version; | 125 value |= version; |
| 128 else | 126 else |
| 129 value &= ~version; | 127 value &= ~version; |
| 130 internet_settings.WriteValue(kProtocolsValueName, value); | 128 internet_settings.WriteValue(kProtocolsValueName, value); |
| 131 // TODO(mattm): We should call UpdateConfig after updating settings, but these | 129 // TODO(mattm): We should call UpdateConfig after updating settings, but these |
| 132 // methods are static. | 130 // methods are static. |
| 133 } | 131 } |
| 134 | 132 |
| 135 void SSLConfigServiceWin::UpdateConfig(TimeTicks now) { | 133 void SSLConfigServiceWin::UpdateConfig(TimeTicks now) { |
| 136 SSLConfig orig_config = config_info_; | 134 SSLConfig orig_config = config_info_; |
| 137 GetSSLConfigNow(&config_info_); | 135 GetSSLConfigNow(&config_info_); |
| 138 if (ever_updated_) | 136 if (ever_updated_) |
| 139 ProcessConfigUpdate(orig_config, config_info_); | 137 ProcessConfigUpdate(orig_config, config_info_); |
| 140 config_time_ = now; | 138 config_time_ = now; |
| 141 ever_updated_ = true; | 139 ever_updated_ = true; |
| 142 } | 140 } |
| 143 | 141 |
| 144 } // namespace net | 142 } // namespace net |
| OLD | NEW |