| OLD | NEW |
| 1 // Copyright (c) 2008-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2010 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_util.h" | 5 #include "base/nss_util.h" |
| 6 #include "base/nss_util_internal.h" | 6 #include "base/nss_util_internal.h" |
| 7 | 7 |
| 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 16 matching lines...) Expand all Loading... |
| 27 // or certificate verification, and we don't use the NSS certificate and key | 27 // or certificate verification, and we don't use the NSS certificate and key |
| 28 // databases. | 28 // databases. |
| 29 #if defined(OS_MACOSX) || defined(OS_WIN) | 29 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 30 #define USE_NSS_FOR_SSL_ONLY 1 | 30 #define USE_NSS_FOR_SSL_ONLY 1 |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 #if !defined(USE_NSS_FOR_SSL_ONLY) | 35 #if !defined(USE_NSS_FOR_SSL_ONLY) |
| 36 std::string GetDefaultConfigDirectory() { | 36 std::string GetDefaultConfigDirectory() { |
| 37 const char* home = getenv("HOME"); | 37 FilePath home = file_util::GetHomeDir(); |
| 38 if (home == NULL) { | 38 if (home.empty()) { |
| 39 LOG(ERROR) << "$HOME is not set."; | 39 LOG(ERROR) << "$HOME is not set."; |
| 40 return ""; | 40 return std::string(); |
| 41 } | 41 } |
| 42 FilePath dir(home); | 42 FilePath dir(home); |
| 43 dir = dir.AppendASCII(".pki").AppendASCII("nssdb"); | 43 dir = dir.AppendASCII(".pki").AppendASCII("nssdb"); |
| 44 if (!file_util::CreateDirectory(dir)) { | 44 if (!file_util::CreateDirectory(dir)) { |
| 45 LOG(ERROR) << "Failed to create ~/.pki/nssdb directory."; | 45 LOG(ERROR) << "Failed to create ~/.pki/nssdb directory."; |
| 46 return ""; | 46 return std::string(); |
| 47 } | 47 } |
| 48 return dir.value(); | 48 return dir.value(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // On non-chromeos platforms, return the default config directory. | 51 // On non-chromeos platforms, return the default config directory. |
| 52 // On chromeos, return a read-only directory with fake root CA certs for testing | 52 // On chromeos, return a read-only directory with fake root CA certs for testing |
| 53 // (which will not exist on non-testing images). These root CA certs are used | 53 // (which will not exist on non-testing images). These root CA certs are used |
| 54 // by the local Google Accounts server mock we use when testing our login code. | 54 // by the local Google Accounts server mock we use when testing our login code. |
| 55 // If this directory is not present, NSS_Init() will fail. It is up to the | 55 // If this directory is not present, NSS_Init() will fail. It is up to the |
| 56 // caller to failover to NSS_NoDB_Init() at that point. | 56 // caller to failover to NSS_NoDB_Init() at that point. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 exploded.millisecond = prxtime.tm_usec / 1000; | 300 exploded.millisecond = prxtime.tm_usec / 1000; |
| 301 | 301 |
| 302 return Time::FromUTCExploded(exploded); | 302 return Time::FromUTCExploded(exploded); |
| 303 } | 303 } |
| 304 | 304 |
| 305 PK11SlotInfo* GetDefaultNSSKeySlot() { | 305 PK11SlotInfo* GetDefaultNSSKeySlot() { |
| 306 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); | 306 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace base | 309 } // namespace base |
| OLD | NEW |