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

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

Issue 2760723002: Check X509Certificate::CreateFromHandle result. (Closed)
Patch Set: 2nd round of updates Created 3 years, 9 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
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 intermediates.pop_back(); 142 intermediates.pop_back();
143 } 143 }
144 144
145 // TODO(svaldez): cert currently wraps cert_context2 which may be backed 145 // TODO(svaldez): cert currently wraps cert_context2 which may be backed
146 // by a smartcard with threading difficulties. Instead, create a fresh 146 // by a smartcard with threading difficulties. Instead, create a fresh
147 // X509Certificate with CreateFromBytes and route cert_context2 into the 147 // X509Certificate with CreateFromBytes and route cert_context2 into the
148 // SSLPrivateKey. Probably changing CertificateList to be a 148 // SSLPrivateKey. Probably changing CertificateList to be a
149 // pair<X509Certificate, SSLPrivateKeyCallback>. 149 // pair<X509Certificate, SSLPrivateKeyCallback>.
150 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( 150 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle(
151 cert_context2, intermediates); 151 cert_context2, intermediates);
152 selected_certs->push_back(cert); 152 if (cert)
153 selected_certs->push_back(std::move(cert));
153 CertFreeCertificateContext(cert_context2); 154 CertFreeCertificateContext(cert_context2);
154 for (size_t i = 0; i < intermediates.size(); ++i) 155 for (size_t i = 0; i < intermediates.size(); ++i)
155 CertFreeCertificateContext(intermediates[i]); 156 CertFreeCertificateContext(intermediates[i]);
156 } 157 }
157 158
158 std::sort(selected_certs->begin(), selected_certs->end(), 159 std::sort(selected_certs->begin(), selected_certs->end(),
159 x509_util::ClientCertSorter()); 160 x509_util::ClientCertSorter());
160 } 161 }
161 162
162 } // namespace 163 } // namespace
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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

Powered by Google App Engine
This is Rietveld 408576698