| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return GetLastError() == CRYPT_E_EXISTS; | 153 return GetLastError() == CRYPT_E_EXISTS; |
| 154 } | 154 } |
| 155 | 155 |
| 156 empty_ = false; | 156 empty_ = false; |
| 157 return true; | 157 return true; |
| 158 } | 158 } |
| 159 | 159 |
| 160 void TestRootCerts::Clear() { | 160 void TestRootCerts::Clear() { |
| 161 empty_ = true; | 161 empty_ = true; |
| 162 | 162 |
| 163 PCCERT_CONTEXT prev_cert = NULL; | 163 for (PCCERT_CONTEXT prev_cert = |
| 164 while (prev_cert = CertEnumCertificatesInStore(temporary_roots_, NULL)) | 164 CertEnumCertificatesInStore(temporary_roots_, NULL); |
| 165 prev_cert; |
| 166 prev_cert = CertEnumCertificatesInStore(temporary_roots_, NULL)) |
| 165 CertDeleteCertificateFromStore(prev_cert); | 167 CertDeleteCertificateFromStore(prev_cert); |
| 166 } | 168 } |
| 167 | 169 |
| 168 bool TestRootCerts::IsEmpty() const { | 170 bool TestRootCerts::IsEmpty() const { |
| 169 return empty_; | 171 return empty_; |
| 170 } | 172 } |
| 171 | 173 |
| 172 HCERTCHAINENGINE TestRootCerts::GetChainEngine() const { | 174 HCERTCHAINENGINE TestRootCerts::GetChainEngine() const { |
| 173 if (IsEmpty()) | 175 if (IsEmpty()) |
| 174 return NULL; // Default chain engine will suffice. | 176 return NULL; // Default chain engine will suffice. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 204 | 206 |
| 205 void TestRootCerts::Init() { | 207 void TestRootCerts::Init() { |
| 206 empty_ = true; | 208 empty_ = true; |
| 207 temporary_roots_ = CertOpenStore( | 209 temporary_roots_ = CertOpenStore( |
| 208 CERT_STORE_PROV_MEMORY, 0, NULL, | 210 CERT_STORE_PROV_MEMORY, 0, NULL, |
| 209 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL); | 211 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG, NULL); |
| 210 DCHECK(temporary_roots_); | 212 DCHECK(temporary_roots_); |
| 211 } | 213 } |
| 212 | 214 |
| 213 } // namespace net | 215 } // namespace net |
| OLD | NEW |