OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ssl/client_cert_store_win.h" | 5 #include "net/ssl/client_cert_store_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #define SECURITY_WIN32 // Needs to be defined before including security.h | 10 #define SECURITY_WIN32 // Needs to be defined before including security.h |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 ClientCertStoreWin::ClientCertStoreWin() {} | 165 ClientCertStoreWin::ClientCertStoreWin() {} |
166 | 166 |
167 ClientCertStoreWin::ClientCertStoreWin(HCERTSTORE cert_store) { | 167 ClientCertStoreWin::ClientCertStoreWin(HCERTSTORE cert_store) { |
168 DCHECK(cert_store); | 168 DCHECK(cert_store); |
169 cert_store_.reset(cert_store); | 169 cert_store_.reset(cert_store); |
170 } | 170 } |
171 | 171 |
172 ClientCertStoreWin::~ClientCertStoreWin() {} | 172 ClientCertStoreWin::~ClientCertStoreWin() {} |
173 | 173 |
174 void ClientCertStoreWin::GetClientCerts(const SSLCertRequestInfo& request, | 174 void ClientCertStoreWin::GetClientCerts( |
175 CertificateList* selected_certs, | 175 const SSLCertRequestInfo& request, |
176 const base::Closure& callback) { | 176 const ClientCertListCallback& callback) { |
| 177 CertificateList selected_certs; |
177 if (cert_store_) { | 178 if (cert_store_) { |
178 // Use the existing client cert store. Note: Under some situations, | 179 // Use the existing client cert store. Note: Under some situations, |
179 // it's possible for this to return certificates that aren't usable | 180 // it's possible for this to return certificates that aren't usable |
180 // (see below). | 181 // (see below). |
181 GetClientCertsImpl(cert_store_, request, selected_certs); | 182 GetClientCertsImpl(cert_store_, request, &selected_certs); |
182 callback.Run(); | 183 callback.Run(std::move(selected_certs)); |
183 return; | 184 return; |
184 } | 185 } |
185 | 186 |
186 // Always open a new instance of the "MY" store, to ensure that there | 187 // Always open a new instance of the "MY" store, to ensure that there |
187 // are no previously cached certificates being reused after they're | 188 // are no previously cached certificates being reused after they're |
188 // no longer available (some smartcard providers fail to update the "MY" | 189 // no longer available (some smartcard providers fail to update the "MY" |
189 // store handles and instead interpose CertOpenSystemStore). | 190 // store handles and instead interpose CertOpenSystemStore). |
190 ScopedHCERTSTORE my_cert_store(CertOpenSystemStore(NULL, L"MY")); | 191 ScopedHCERTSTORE my_cert_store(CertOpenSystemStore(NULL, L"MY")); |
191 if (!my_cert_store) { | 192 if (!my_cert_store) { |
192 PLOG(ERROR) << "Could not open the \"MY\" system certificate store: "; | 193 PLOG(ERROR) << "Could not open the \"MY\" system certificate store: "; |
193 selected_certs->clear(); | 194 callback.Run(CertificateList()); |
194 callback.Run(); | |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 GetClientCertsImpl(my_cert_store, request, selected_certs); | 198 GetClientCertsImpl(my_cert_store, request, &selected_certs); |
199 | 199 callback.Run(std::move(selected_certs)); |
200 callback.Run(); | |
201 } | 200 } |
202 | 201 |
203 bool ClientCertStoreWin::SelectClientCertsForTesting( | 202 bool ClientCertStoreWin::SelectClientCertsForTesting( |
204 const CertificateList& input_certs, | 203 const CertificateList& input_certs, |
205 const SSLCertRequestInfo& request, | 204 const SSLCertRequestInfo& request, |
206 CertificateList* selected_certs) { | 205 CertificateList* selected_certs) { |
207 ScopedHCERTSTORE test_store(CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, 0, | 206 ScopedHCERTSTORE test_store(CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, 0, |
208 NULL)); | 207 NULL)); |
209 if (!test_store) | 208 if (!test_store) |
210 return false; | 209 return false; |
(...skipping 20 matching lines...) Expand all Loading... |
231 // copy). | 230 // copy). |
232 if (!CertFreeCertificateContext(cert)) | 231 if (!CertFreeCertificateContext(cert)) |
233 return false; | 232 return false; |
234 } | 233 } |
235 | 234 |
236 GetClientCertsImpl(test_store.get(), request, selected_certs); | 235 GetClientCertsImpl(test_store.get(), request, selected_certs); |
237 return true; | 236 return true; |
238 } | 237 } |
239 | 238 |
240 } // namespace net | 239 } // namespace net |
OLD | NEW |