| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/network/client_cert_util.h" | 5 #include "chromeos/network/client_cert_util.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 pattern.organizational_unit()) == | 131 pattern.organizational_unit()) == |
| 132 principal.organization_unit_names.end()) { | 132 principal.organization_unit_names.end()) { |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 return true; | 137 return true; |
| 138 } | 138 } |
| 139 | 139 |
| 140 scoped_refptr<net::X509Certificate> GetCertificateMatch( | 140 scoped_refptr<net::X509Certificate> GetCertificateMatch( |
| 141 const CertificatePattern& pattern) { | 141 const CertificatePattern& pattern, |
| 142 const net::CertificateList& all_certs) { |
| 142 typedef std::list<scoped_refptr<net::X509Certificate> > CertificateStlList; | 143 typedef std::list<scoped_refptr<net::X509Certificate> > CertificateStlList; |
| 143 | 144 |
| 144 // Start with all the certs, and narrow it down from there. | 145 // Start with all the certs, and narrow it down from there. |
| 145 net::CertificateList all_certs; | |
| 146 CertificateStlList matching_certs; | 146 CertificateStlList matching_certs; |
| 147 net::NSSCertDatabase::GetInstance()->ListCerts(&all_certs); | |
| 148 | 147 |
| 149 if (all_certs.empty()) | 148 if (all_certs.empty()) |
| 150 return NULL; | 149 return NULL; |
| 151 | 150 |
| 152 for (net::CertificateList::iterator iter = all_certs.begin(); | 151 for (net::CertificateList::const_iterator iter = all_certs.begin(); |
| 153 iter != all_certs.end(); ++iter) { | 152 iter != all_certs.end(); ++iter) { |
| 154 matching_certs.push_back(*iter); | 153 matching_certs.push_back(*iter); |
| 155 } | 154 } |
| 156 | 155 |
| 157 // Strip off any certs that don't have the right issuer and/or subject. | 156 // Strip off any certs that don't have the right issuer and/or subject. |
| 158 if (!pattern.issuer().Empty()) { | 157 if (!pattern.issuer().Empty()) { |
| 159 matching_certs.remove_if(IssuerFilter(pattern.issuer())); | 158 matching_certs.remove_if(IssuerFilter(pattern.issuer())); |
| 160 if (matching_certs.empty()) | 159 if (matching_certs.empty()) |
| 161 return NULL; | 160 return NULL; |
| 162 } | 161 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return !cert_id.empty() && !key_id.empty() && !identity.empty(); | 270 return !cert_id.empty() && !key_id.empty() && !identity.empty(); |
| 272 } | 271 } |
| 273 } | 272 } |
| 274 NOTREACHED(); | 273 NOTREACHED(); |
| 275 return false; | 274 return false; |
| 276 } | 275 } |
| 277 | 276 |
| 278 } // namespace client_cert | 277 } // namespace client_cert |
| 279 | 278 |
| 280 } // namespace chromeos | 279 } // namespace chromeos |
| OLD | NEW |