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

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

Issue 556243003: Make the private slot optional in NSSCertDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
OLDNEW
« no previous file with comments | « net/cert/nss_cert_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698