| OLD | NEW |
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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 "base/nss_init.h" | 5 #include "base/nss_init.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <nss.h> | 8 #include <nss.h> |
| 9 #include <plarena.h> | 9 #include <plarena.h> |
| 10 #include <prerror.h> | 10 #include <prerror.h> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 class NSSInitSingleton { | 75 class NSSInitSingleton { |
| 76 public: | 76 public: |
| 77 NSSInitSingleton() { | 77 NSSInitSingleton() { |
| 78 base::EnsureNSPRInit(); | 78 base::EnsureNSPRInit(); |
| 79 | 79 |
| 80 SECStatus status = SECFailure; | 80 SECStatus status = SECFailure; |
| 81 std::string database_dir = GetDefaultConfigDirectory(); | 81 std::string database_dir = GetDefaultConfigDirectory(); |
| 82 if (!database_dir.empty()) { | 82 if (!database_dir.empty()) { |
| 83 // Initialize with a persistant database (~/.pki/nssdb). | 83 // Initialize with a persistant database (~/.pki/nssdb). |
| 84 // Use "sql:" which can be shared by multiple processes safely. | 84 // Use "sql:" which can be shared by multiple processes safely. |
| 85 status = NSS_InitReadWrite( | 85 std::string nss_config_dir = |
| 86 StringPrintf("sql:%s", database_dir.c_str()).c_str()); | 86 StringPrintf("sql:%s", database_dir.c_str()); |
| 87 status = NSS_InitReadWrite(nss_config_dir.c_str()); |
| 87 if (status != SECSuccess) { | 88 if (status != SECSuccess) { |
| 88 LOG(ERROR) << "Error initializing NSS with a persistent " | 89 LOG(ERROR) << "Error initializing NSS with a persistent " |
| 89 "databases: NSS error code " << PR_GetError(); | 90 "database (" << nss_config_dir |
| 91 << "): NSS error code " << PR_GetError(); |
| 90 } | 92 } |
| 91 } | 93 } |
| 92 if (status != SECSuccess) { | 94 if (status != SECSuccess) { |
| 93 LOG(WARNING) << "Initialize NSS without a persistent database " | 95 LOG(WARNING) << "Initialize NSS without a persistent database " |
| 94 "(~/.pki/nssdb)."; | 96 "(~/.pki/nssdb)."; |
| 95 status = NSS_NoDB_Init(NULL); | 97 status = NSS_NoDB_Init(NULL); |
| 96 if (status != SECSuccess) { | 98 if (status != SECSuccess) { |
| 97 LOG(ERROR) << "Error initializing NSS without a persistent " | 99 LOG(ERROR) << "Error initializing NSS without a persistent " |
| 98 "database: NSS error code " << PR_GetError(); | 100 "database: NSS error code " << PR_GetError(); |
| 99 } | 101 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 172 |
| 171 void EnsureNSPRInit() { | 173 void EnsureNSPRInit() { |
| 172 Singleton<NSPRInitSingleton>::get(); | 174 Singleton<NSPRInitSingleton>::get(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 void EnsureNSSInit() { | 177 void EnsureNSSInit() { |
| 176 Singleton<NSSInitSingleton>::get(); | 178 Singleton<NSSInitSingleton>::get(); |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace base | 181 } // namespace base |
| OLD | NEW |