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

Unified Diff: net/cert/nss_cert_database.cc

Issue 111273002: NSSCertDatabaseChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gcc fix Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/nss_cert_database.cc
diff --git a/net/cert/nss_cert_database.cc b/net/cert/nss_cert_database.cc
index d4ece1057454ff70ddb6c27896b9dda6e5513a02..73f6ec9f56be72fb7d9266849a81802dbe852920 100644
--- a/net/cert/nss_cert_database.cc
+++ b/net/cert/nss_cert_database.cc
@@ -10,9 +10,9 @@
#include <pk11pub.h>
#include <secmod.h>
+#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
#include "base/observer_list_threadsafe.h"
#include "crypto/nss_util.h"
#include "crypto/nss_util_internal.h"
@@ -35,6 +35,14 @@ namespace psm = mozilla_security_manager;
namespace net {
+namespace {
+
+base::LazyInstance<NSSCertDatabase>::Leaky
+ g_nss_cert_database = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+
NSSCertDatabase::ImportCertFailure::ImportCertFailure(
const scoped_refptr<X509Certificate>& cert,
int err)
@@ -44,13 +52,18 @@ NSSCertDatabase::ImportCertFailure::~ImportCertFailure() {}
// static
NSSCertDatabase* NSSCertDatabase::GetInstance() {
- return Singleton<NSSCertDatabase,
- LeakySingletonTraits<NSSCertDatabase> >::get();
+#if defined(OS_CHROMEOS)
+ DVLOG(1) << "Using global NSSCertDatabase. Consider using "
+ << "NSSCertDatabaseChromeOS::GetForUser instead.";
+#endif
+ return &g_nss_cert_database.Get();
}
NSSCertDatabase::NSSCertDatabase()
: observer_list_(new ObserverListThreadSafe<Observer>) {
- crypto::EnsureNSSInit();
+ // This also makes sure that NSS has been initialized.
+ CertDatabase::GetInstance()->AddSource(this);
+
psm::EnsurePKCS12Init();
}
@@ -117,6 +130,9 @@ int NSSCertDatabase::ImportFromPKCS12(
const base::string16& password,
bool is_extractable,
net::CertificateList* imported_certs) {
+ DVLOG(1) << __func__ << " "
+ << PK11_GetModuleID(module->os_module_handle()) << ":"
+ << PK11_GetSlotID(module->os_module_handle());
int result = psm::nsPKCS12Blob_Import(module->os_module_handle(),
data.data(), data.size(),
password,
@@ -154,7 +170,7 @@ X509Certificate* NSSCertDatabase::FindRootInList(
&certn_1->os_cert_handle()->subject) == SECEqual)
return certn_1;
- VLOG(1) << "certificate list is not a hierarchy";
+ LOG(WARNING) << "certificate list is not a hierarchy";
return cert0;
}

Powered by Google App Engine
This is Rietveld 408576698