| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 : certificate(cert), net_error(err) {} | 77 : certificate(cert), net_error(err) {} |
| 78 | 78 |
| 79 NSSCertDatabase::ImportCertFailure::~ImportCertFailure() {} | 79 NSSCertDatabase::ImportCertFailure::~ImportCertFailure() {} |
| 80 | 80 |
| 81 NSSCertDatabase::NSSCertDatabase(crypto::ScopedPK11Slot public_slot, | 81 NSSCertDatabase::NSSCertDatabase(crypto::ScopedPK11Slot public_slot, |
| 82 crypto::ScopedPK11Slot private_slot) | 82 crypto::ScopedPK11Slot private_slot) |
| 83 : public_slot_(public_slot.Pass()), | 83 : public_slot_(public_slot.Pass()), |
| 84 private_slot_(private_slot.Pass()), | 84 private_slot_(private_slot.Pass()), |
| 85 observer_list_(new ObserverListThreadSafe<Observer>), | 85 observer_list_(new ObserverListThreadSafe<Observer>), |
| 86 weak_factory_(this) { | 86 weak_factory_(this) { |
| 87 DCHECK(public_slot_); | 87 CHECK(public_slot_); |
| 88 DCHECK(private_slot_); | |
| 89 | 88 |
| 90 // This also makes sure that NSS has been initialized. | 89 // This also makes sure that NSS has been initialized. |
| 91 CertDatabase* cert_db = CertDatabase::GetInstance(); | 90 CertDatabase* cert_db = CertDatabase::GetInstance(); |
| 92 cert_notification_forwarder_.reset(new CertNotificationForwarder(cert_db)); | 91 cert_notification_forwarder_.reset(new CertNotificationForwarder(cert_db)); |
| 93 AddObserver(cert_notification_forwarder_.get()); | 92 AddObserver(cert_notification_forwarder_.get()); |
| 94 | 93 |
| 95 psm::EnsurePKCS12Init(); | 94 psm::EnsurePKCS12Init(); |
| 96 } | 95 } |
| 97 | 96 |
| 98 NSSCertDatabase::~NSSCertDatabase() {} | 97 NSSCertDatabase::~NSSCertDatabase() {} |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 crypto::ScopedPK11Slot NSSCertDatabase::GetSystemSlot() const { | 133 crypto::ScopedPK11Slot NSSCertDatabase::GetSystemSlot() const { |
| 135 return crypto::ScopedPK11Slot(); | 134 return crypto::ScopedPK11Slot(); |
| 136 } | 135 } |
| 137 #endif | 136 #endif |
| 138 | 137 |
| 139 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { | 138 crypto::ScopedPK11Slot NSSCertDatabase::GetPublicSlot() const { |
| 140 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get())); | 139 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(public_slot_.get())); |
| 141 } | 140 } |
| 142 | 141 |
| 143 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { | 142 crypto::ScopedPK11Slot NSSCertDatabase::GetPrivateSlot() const { |
| 143 if (!private_slot_) |
| 144 return crypto::ScopedPK11Slot(); |
| 144 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get())); | 145 return crypto::ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get())); |
| 145 } | 146 } |
| 146 | 147 |
| 147 CryptoModule* NSSCertDatabase::GetPublicModule() const { | 148 CryptoModule* NSSCertDatabase::GetPublicModule() const { |
| 148 crypto::ScopedPK11Slot slot(GetPublicSlot()); | 149 crypto::ScopedPK11Slot slot(GetPublicSlot()); |
| 149 return CryptoModule::CreateFromHandle(slot.get()); | 150 return CryptoModule::CreateFromHandle(slot.get()); |
| 150 } | 151 } |
| 151 | 152 |
| 152 CryptoModule* NSSCertDatabase::GetPrivateModule() const { | 153 CryptoModule* NSSCertDatabase::GetPrivateModule() const { |
| 153 crypto::ScopedPK11Slot slot(GetPrivateSlot()); | 154 crypto::ScopedPK11Slot slot(GetPrivateSlot()); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } else { | 470 } else { |
| 470 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { | 471 if (SEC_DeletePermCertificate(cert->os_cert_handle())) { |
| 471 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); | 472 LOG(ERROR) << "SEC_DeletePermCertificate failed: " << PORT_GetError(); |
| 472 return false; | 473 return false; |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 return true; | 476 return true; |
| 476 } | 477 } |
| 477 | 478 |
| 478 } // namespace net | 479 } // namespace net |
| OLD | NEW |