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