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 "net/cert/nss_cert_database.h" | 5 #include "net/cert/nss_cert_database.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <certdb.h> | 8 #include <certdb.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 &cert0->os_cert_handle()->subject) == SECEqual) | 220 &cert0->os_cert_handle()->subject) == SECEqual) |
221 return cert0; | 221 return cert0; |
222 if (CERT_CompareName(&certn_2->os_cert_handle()->issuer, | 222 if (CERT_CompareName(&certn_2->os_cert_handle()->issuer, |
223 &certn_1->os_cert_handle()->subject) == SECEqual) | 223 &certn_1->os_cert_handle()->subject) == SECEqual) |
224 return certn_1; | 224 return certn_1; |
225 | 225 |
226 LOG(WARNING) << "certificate list is not a hierarchy"; | 226 LOG(WARNING) << "certificate list is not a hierarchy"; |
227 return cert0; | 227 return cert0; |
228 } | 228 } |
229 | 229 |
| 230 int NSSCertDatabase::ImportUserCert(const std::string& data) { |
| 231 CertificateList certificates = |
| 232 X509Certificate::CreateCertificateListFromBytes( |
| 233 data.c_str(), data.size(), net::X509Certificate::FORMAT_AUTO); |
| 234 int result = psm::ImportUserCert(certificates); |
| 235 |
| 236 if (result == OK) |
| 237 NotifyObserversOfCertAdded(NULL); |
| 238 |
| 239 return result; |
| 240 } |
| 241 |
230 bool NSSCertDatabase::ImportCACerts(const CertificateList& certificates, | 242 bool NSSCertDatabase::ImportCACerts(const CertificateList& certificates, |
231 TrustBits trust_bits, | 243 TrustBits trust_bits, |
232 ImportCertFailureList* not_imported) { | 244 ImportCertFailureList* not_imported) { |
233 crypto::ScopedPK11Slot slot(GetPublicSlot()); | 245 crypto::ScopedPK11Slot slot(GetPublicSlot()); |
234 X509Certificate* root = FindRootInList(certificates); | 246 X509Certificate* root = FindRootInList(certificates); |
235 bool success = psm::ImportCACerts( | 247 bool success = psm::ImportCACerts( |
236 slot.get(), certificates, root, trust_bits, not_imported); | 248 slot.get(), certificates, root, trust_bits, not_imported); |
237 if (success) | 249 if (success) |
238 NotifyObserversOfCACertChanged(NULL); | 250 NotifyObserversOfCACertChanged(NULL); |
239 | 251 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } else { | 483 } else { |
472 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { | 484 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { |
473 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); | 485 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); |
474 return false; | 486 return false; |
475 } | 487 } |
476 } | 488 } |
477 return true; | 489 return true; |
478 } | 490 } |
479 | 491 |
480 } // namespace net | 492 } // namespace net |
OLD | NEW |