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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 for (DWORD i = 1; i < chain_context->rgpChain[0]->cElement; ++i) { | 121 for (DWORD i = 1; i < chain_context->rgpChain[0]->cElement; ++i) { |
122 PCCERT_CONTEXT chain_intermediate = | 122 PCCERT_CONTEXT chain_intermediate = |
123 chain_context->rgpChain[0]->rgpElement[i]->pCertContext; | 123 chain_context->rgpChain[0]->rgpElement[i]->pCertContext; |
124 PCCERT_CONTEXT copied_intermediate = NULL; | 124 PCCERT_CONTEXT copied_intermediate = NULL; |
125 ok = CertAddCertificateContextToStore(NULL, chain_intermediate, | 125 ok = CertAddCertificateContextToStore(NULL, chain_intermediate, |
126 CERT_STORE_ADD_USE_EXISTING, | 126 CERT_STORE_ADD_USE_EXISTING, |
127 &copied_intermediate); | 127 &copied_intermediate); |
128 if (ok) | 128 if (ok) |
129 intermediates.push_back(copied_intermediate); | 129 intermediates.push_back(copied_intermediate); |
130 } | 130 } |
| 131 // TODO(svaldez): cert currently wraps cert_context2 which may be backed |
| 132 // by a smartcard with threading difficulties. Instead, create a fresh |
| 133 // X509Certificate with CreateFromBytes and route cert_context2 into the |
| 134 // SSLPrivateKey. Probably changing CertificateList to be a |
| 135 // pair<X509Certificate, SSLPrivateKeyCallback>. |
131 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( | 136 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( |
132 cert_context2, intermediates); | 137 cert_context2, intermediates); |
133 selected_certs->push_back(cert); | 138 selected_certs->push_back(cert); |
134 CertFreeCertificateContext(cert_context2); | 139 CertFreeCertificateContext(cert_context2); |
135 for (size_t i = 0; i < intermediates.size(); ++i) | 140 for (size_t i = 0; i < intermediates.size(); ++i) |
136 CertFreeCertificateContext(intermediates[i]); | 141 CertFreeCertificateContext(intermediates[i]); |
137 } | 142 } |
138 | 143 |
139 std::sort(selected_certs->begin(), selected_certs->end(), | 144 std::sort(selected_certs->begin(), selected_certs->end(), |
140 x509_util::ClientCertSorter()); | 145 x509_util::ClientCertSorter()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // copy). | 216 // copy). |
212 if (!CertFreeCertificateContext(cert)) | 217 if (!CertFreeCertificateContext(cert)) |
213 return false; | 218 return false; |
214 } | 219 } |
215 | 220 |
216 GetClientCertsImpl(test_store.get(), request, selected_certs); | 221 GetClientCertsImpl(test_store.get(), request, selected_certs); |
217 return true; | 222 return true; |
218 } | 223 } |
219 | 224 |
220 } // namespace net | 225 } // namespace net |
OLD | NEW |