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