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

Side by Side Diff: net/ssl/client_cert_store_win.cc

Issue 2848313003: Revert of Remove client_certs from SSLCertRequestInfo. (Closed)
Patch Set: Created 3 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/ssl/client_cert_store_win.h ('k') | net/ssl/ssl_cert_request_info.h » ('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 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
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( 174 void ClientCertStoreWin::GetClientCerts(const SSLCertRequestInfo& request,
175 const SSLCertRequestInfo& request, 175 CertificateList* selected_certs,
176 const ClientCertListCallback& callback) { 176 const base::Closure& callback) {
177 CertificateList selected_certs;
178 if (cert_store_) { 177 if (cert_store_) {
179 // Use the existing client cert store. Note: Under some situations, 178 // Use the existing client cert store. Note: Under some situations,
180 // it's possible for this to return certificates that aren't usable 179 // it's possible for this to return certificates that aren't usable
181 // (see below). 180 // (see below).
182 GetClientCertsImpl(cert_store_, request, &selected_certs); 181 GetClientCertsImpl(cert_store_, request, selected_certs);
183 callback.Run(std::move(selected_certs)); 182 callback.Run();
184 return; 183 return;
185 } 184 }
186 185
187 // Always open a new instance of the "MY" store, to ensure that there 186 // Always open a new instance of the "MY" store, to ensure that there
188 // are no previously cached certificates being reused after they're 187 // are no previously cached certificates being reused after they're
189 // no longer available (some smartcard providers fail to update the "MY" 188 // no longer available (some smartcard providers fail to update the "MY"
190 // store handles and instead interpose CertOpenSystemStore). 189 // store handles and instead interpose CertOpenSystemStore).
191 ScopedHCERTSTORE my_cert_store(CertOpenSystemStore(NULL, L"MY")); 190 ScopedHCERTSTORE my_cert_store(CertOpenSystemStore(NULL, L"MY"));
192 if (!my_cert_store) { 191 if (!my_cert_store) {
193 PLOG(ERROR) << "Could not open the \"MY\" system certificate store: "; 192 PLOG(ERROR) << "Could not open the \"MY\" system certificate store: ";
194 callback.Run(CertificateList()); 193 selected_certs->clear();
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 callback.Run(std::move(selected_certs)); 199
200 callback.Run();
200 } 201 }
201 202
202 bool ClientCertStoreWin::SelectClientCertsForTesting( 203 bool ClientCertStoreWin::SelectClientCertsForTesting(
203 const CertificateList& input_certs, 204 const CertificateList& input_certs,
204 const SSLCertRequestInfo& request, 205 const SSLCertRequestInfo& request,
205 CertificateList* selected_certs) { 206 CertificateList* selected_certs) {
206 ScopedHCERTSTORE test_store(CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, 0, 207 ScopedHCERTSTORE test_store(CertOpenStore(CERT_STORE_PROV_MEMORY, 0, NULL, 0,
207 NULL)); 208 NULL));
208 if (!test_store) 209 if (!test_store)
209 return false; 210 return false;
(...skipping 20 matching lines...) Expand all
230 // copy). 231 // copy).
231 if (!CertFreeCertificateContext(cert)) 232 if (!CertFreeCertificateContext(cert))
232 return false; 233 return false;
233 } 234 }
234 235
235 GetClientCertsImpl(test_store.get(), request, selected_certs); 236 GetClientCertsImpl(test_store.get(), request, selected_certs);
236 return true; 237 return true;
237 } 238 }
238 239
239 } // namespace net 240 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/client_cert_store_win.h ('k') | net/ssl/ssl_cert_request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698