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

Side by Side Diff: net/cert/nss_cert_database.cc

Issue 1423333006: Adding User Certificate (.crt) Import to Certificate Manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 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 (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
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
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
OLDNEW
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | net/third_party/mozilla_security_manager/nsNSSCertificateDB.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698