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

Side by Side Diff: net/cert/test_root_certs_win.cc

Issue 1987793002: Remove Windows Vista/XP specific code from net/cert and net/ssl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « net/cert/cert_verify_proc_unittest.cc ('k') | net/cert/x509_certificate_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 #include "net/cert/test_root_certs.h" 5 #include "net/cert/test_root_certs.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/win/win_util.h" 11 #include "base/win/win_util.h"
12 #include "base/win/windows_version.h"
13 #include "net/cert/x509_certificate.h" 12 #include "net/cert/x509_certificate.h"
14 13
15 namespace net { 14 namespace net {
16 15
17 namespace { 16 namespace {
18 17
19 // Provides a CertDllOpenStoreProv callback provider function, to be called 18 // Provides a CertDllOpenStoreProv callback provider function, to be called
20 // by CertOpenStore when the CERT_STORE_PROV_SYSTEM_W store is opened. See 19 // by CertOpenStore when the CERT_STORE_PROV_SYSTEM_W store is opened. See
21 // http://msdn.microsoft.com/en-us/library/aa376043(VS.85).aspx. 20 // http://msdn.microsoft.com/en-us/library/aa376043(VS.85).aspx.
22 BOOL WINAPI InterceptedOpenStoreW(LPCSTR store_provider, 21 BOOL WINAPI InterceptedOpenStoreW(LPCSTR store_provider,
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 165 }
167 166
168 bool TestRootCerts::IsEmpty() const { 167 bool TestRootCerts::IsEmpty() const {
169 return empty_; 168 return empty_;
170 } 169 }
171 170
172 HCERTCHAINENGINE TestRootCerts::GetChainEngine() const { 171 HCERTCHAINENGINE TestRootCerts::GetChainEngine() const {
173 if (IsEmpty()) 172 if (IsEmpty())
174 return NULL; // Default chain engine will suffice. 173 return NULL; // Default chain engine will suffice.
175 174
176 // Windows versions before 7 don't accept the struct size for later versions.
177 // We report the size of the old struct since we don't need the new members.
178 static const DWORD kSizeofCertChainEngineConfig =
179 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(
180 CERT_CHAIN_ENGINE_CONFIG, CycleDetectionModulus);
181
182 // Each HCERTCHAINENGINE caches both the configured system stores and 175 // Each HCERTCHAINENGINE caches both the configured system stores and
183 // information about each chain that has been built. In order to ensure 176 // information about each chain that has been built. In order to ensure
184 // that changes to |temporary_roots_| are properly propagated and that the 177 // that changes to |temporary_roots_| are properly propagated and that the
185 // various caches are flushed, when at least one certificate is added, 178 // various caches are flushed, when at least one certificate is added,
186 // return a new chain engine for every call. Each chain engine creation 179 // return a new chain engine for every call. Each chain engine creation
187 // should re-open the root store, ensuring the most recent changes are 180 // should re-open the root store, ensuring the most recent changes are
188 // visible. 181 // visible.
189 CERT_CHAIN_ENGINE_CONFIG engine_config = { 182 CERT_CHAIN_ENGINE_CONFIG engine_config = {sizeof(CERT_CHAIN_ENGINE_CONFIG)};
Ryan Sleevi 2016/05/17 20:26:01 CERT_CHAIN_ENGINE_CONFIG engine_config = {0}; engi
martijnc 2016/05/19 21:27:33 I kept the old code but included the 2 fields that
190 kSizeofCertChainEngineConfig
191 };
192 engine_config.dwFlags = 183 engine_config.dwFlags =
193 CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE | 184 CERT_CHAIN_ENABLE_CACHE_AUTO_UPDATE |
194 CERT_CHAIN_ENABLE_SHARE_STORE; 185 CERT_CHAIN_ENABLE_SHARE_STORE;
195 HCERTCHAINENGINE chain_engine = NULL; 186 HCERTCHAINENGINE chain_engine = NULL;
196 BOOL ok = CertCreateCertificateChainEngine(&engine_config, &chain_engine); 187 BOOL ok = CertCreateCertificateChainEngine(&engine_config, &chain_engine);
197 DCHECK(ok); 188 DCHECK(ok);
198 return chain_engine; 189 return chain_engine;
199 } 190 }
200 191
201 TestRootCerts::~TestRootCerts() { 192 TestRootCerts::~TestRootCerts() {
202 CertCloseStore(temporary_roots_, 0); 193 CertCloseStore(temporary_roots_, 0);
203 } 194 }
204 195
205 void TestRootCerts::Init() { 196 void TestRootCerts::Init() {
206 empty_ = true; 197 empty_ = true;
207 temporary_roots_ = CertOpenStore( 198 temporary_roots_ = CertOpenStore(
208 CERT_STORE_PROV_MEMORY, 0, NULL, 199 CERT_STORE_PROV_MEMORY, 0, NULL,
209 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL); 200 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL);
210 DCHECK(temporary_roots_); 201 DCHECK(temporary_roots_);
211 } 202 }
212 203
213 } // namespace net 204 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/cert_verify_proc_unittest.cc ('k') | net/cert/x509_certificate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698