| 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_nss.h" | 5 #include "net/ssl/client_cert_store_nss.h" |
| 6 | 6 |
| 7 #include <nss.h> | 7 #include <nss.h> |
| 8 #include <ssl.h> | 8 #include <ssl.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 void ClientCertStoreNSS::GetClientCertsOnWorkerThread( | 116 void ClientCertStoreNSS::GetClientCertsOnWorkerThread( |
| 117 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> password_delegate, | 117 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> password_delegate, |
| 118 const SSLCertRequestInfo* request, | 118 const SSLCertRequestInfo* request, |
| 119 CertificateList* selected_certs) { | 119 CertificateList* selected_certs) { |
| 120 CERTCertList* client_certs = CERT_FindUserCertsByUsage( | 120 CERTCertList* client_certs = CERT_FindUserCertsByUsage( |
| 121 CERT_GetDefaultCertDB(), | 121 CERT_GetDefaultCertDB(), |
| 122 certUsageSSLClient, | 122 certUsageSSLClient, |
| 123 PR_FALSE, | 123 PR_FALSE, |
| 124 PR_FALSE, | 124 PR_FALSE, |
| 125 password_delegate.get()); | 125 password_delegate.get()); |
| 126 // It is ok for a user not to have any client certs. | |
| 127 if (!client_certs) { | 126 if (!client_certs) { |
| 128 DVLOG(2) << "No client certs found."; | 127 DVLOG(2) << "No client certs found."; |
| 129 selected_certs->clear(); | 128 client_certs = CERT_NewCertList(); |
| 130 return; | |
| 131 } | 129 } |
| 132 | 130 |
| 133 GetClientCertsImpl(client_certs, *request, true, selected_certs); | 131 GetClientCertsImpl(client_certs, *request, true, selected_certs); |
| 134 CERT_DestroyCertList(client_certs); | 132 CERT_DestroyCertList(client_certs); |
| 135 } | 133 } |
| 136 | 134 |
| 137 bool ClientCertStoreNSS::SelectClientCertsForTesting( | 135 bool ClientCertStoreNSS::SelectClientCertsForTesting( |
| 138 const CertificateList& input_certs, | 136 const CertificateList& input_certs, |
| 139 const SSLCertRequestInfo& request, | 137 const SSLCertRequestInfo& request, |
| 140 CertificateList* selected_certs) { | 138 CertificateList* selected_certs) { |
| 141 CERTCertList* cert_list = CERT_NewCertList(); | 139 CERTCertList* cert_list = CERT_NewCertList(); |
| 142 if (!cert_list) | 140 if (!cert_list) |
| 143 return false; | 141 return false; |
| 144 for (size_t i = 0; i < input_certs.size(); ++i) { | 142 for (size_t i = 0; i < input_certs.size(); ++i) { |
| 145 CERT_AddCertToListTail( | 143 CERT_AddCertToListTail( |
| 146 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); | 144 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle())); |
| 147 } | 145 } |
| 148 | 146 |
| 149 GetClientCertsImpl(cert_list, request, false, selected_certs); | 147 GetClientCertsImpl(cert_list, request, false, selected_certs); |
| 150 CERT_DestroyCertList(cert_list); | 148 CERT_DestroyCertList(cert_list); |
| 151 return true; | 149 return true; |
| 152 } | 150 } |
| 153 | 151 |
| 154 } // namespace net | 152 } // namespace net |
| OLD | NEW |