| 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 | 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 Loading... |
| 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. | 175 // Windows versions before 8 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. | 176 // We report the size of the old struct since we don't need the new members. |
| 178 static const DWORD kSizeofCertChainEngineConfig = | 177 static const DWORD kSizeofCertChainEngineConfig = |
| 179 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER( | 178 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(CERT_CHAIN_ENGINE_CONFIG, |
| 180 CERT_CHAIN_ENGINE_CONFIG, CycleDetectionModulus); | 179 hExclusiveTrustedPeople); |
| 181 | 180 |
| 182 // Each HCERTCHAINENGINE caches both the configured system stores and | 181 // Each HCERTCHAINENGINE caches both the configured system stores and |
| 183 // information about each chain that has been built. In order to ensure | 182 // information about each chain that has been built. In order to ensure |
| 184 // that changes to |temporary_roots_| are properly propagated and that the | 183 // that changes to |temporary_roots_| are properly propagated and that the |
| 185 // various caches are flushed, when at least one certificate is added, | 184 // various caches are flushed, when at least one certificate is added, |
| 186 // return a new chain engine for every call. Each chain engine creation | 185 // 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 | 186 // should re-open the root store, ensuring the most recent changes are |
| 188 // visible. | 187 // visible. |
| 189 CERT_CHAIN_ENGINE_CONFIG engine_config = { | 188 CERT_CHAIN_ENGINE_CONFIG engine_config = { |
| 190 kSizeofCertChainEngineConfig | 189 kSizeofCertChainEngineConfig |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 | 203 |
| 205 void TestRootCerts::Init() { | 204 void TestRootCerts::Init() { |
| 206 empty_ = true; | 205 empty_ = true; |
| 207 temporary_roots_ = CertOpenStore( | 206 temporary_roots_ = CertOpenStore( |
| 208 CERT_STORE_PROV_MEMORY, 0, NULL, | 207 CERT_STORE_PROV_MEMORY, 0, NULL, |
| 209 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL); | 208 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL); |
| 210 DCHECK(temporary_roots_); | 209 DCHECK(temporary_roots_); |
| 211 } | 210 } |
| 212 | 211 |
| 213 } // namespace net | 212 } // namespace net |
| OLD | NEW |