OLD | NEW |
1 // Copyright (c) 2008-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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> |
11 #include <prinit.h> | 11 #include <prinit.h> |
12 #include <prtime.h> | 12 #include <prtime.h> |
13 #include <pk11pub.h> | 13 #include <pk11pub.h> |
14 #include <secmod.h> | 14 #include <secmod.h> |
15 | 15 |
16 #if defined(OS_LINUX) | 16 #if defined(OS_LINUX) |
17 #include <linux/magic.h> | 17 #include <linux/magic.h> |
18 #include <sys/vfs.h> | 18 #include <sys/vfs.h> |
19 #endif | 19 #endif |
20 | 20 |
21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
22 #include "base/logging.h" | 22 #include "base/logging.h" |
23 #include "base/singleton.h" | 23 #include "base/singleton.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 | 25 |
26 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not | 26 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not |
27 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't | 27 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't |
28 // use NSS for crypto or certificate verification, and we don't use the NSS | 28 // use NSS for crypto or certificate verification, and we don't use the NSS |
29 // certificate and key databases. | 29 // certificate and key databases. |
30 #if defined(USE_NSS) | 30 #if defined(USE_NSS) |
31 #include "base/env_var.h" | 31 #include "base/environment.h" |
32 #include "base/lock.h" | 32 #include "base/lock.h" |
33 #include "base/scoped_ptr.h" | 33 #include "base/scoped_ptr.h" |
34 #endif // defined(USE_NSS) | 34 #endif // defined(USE_NSS) |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 #if defined(USE_NSS) | 38 #if defined(USE_NSS) |
39 FilePath GetDefaultConfigDirectory() { | 39 FilePath GetDefaultConfigDirectory() { |
40 FilePath dir = file_util::GetHomeDir(); | 40 FilePath dir = file_util::GetHomeDir(); |
41 if (dir.empty()) { | 41 if (dir.empty()) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // the NSS environment variable NSS_SDB_USE_CACHE to "yes" to override NSS's | 73 // the NSS environment variable NSS_SDB_USE_CACHE to "yes" to override NSS's |
74 // detection when database_dir is on NFS. See http://crbug.com/48585. | 74 // detection when database_dir is on NFS. See http://crbug.com/48585. |
75 // | 75 // |
76 // TODO(wtc): port this function to other USE_NSS platforms. It is defined | 76 // TODO(wtc): port this function to other USE_NSS platforms. It is defined |
77 // only for OS_LINUX simply because the statfs structure is OS-specific. | 77 // only for OS_LINUX simply because the statfs structure is OS-specific. |
78 void UseLocalCacheOfNSSDatabaseIfNFS(const FilePath& database_dir) { | 78 void UseLocalCacheOfNSSDatabaseIfNFS(const FilePath& database_dir) { |
79 #if defined(OS_LINUX) | 79 #if defined(OS_LINUX) |
80 struct statfs buf; | 80 struct statfs buf; |
81 if (statfs(database_dir.value().c_str(), &buf) == 0) { | 81 if (statfs(database_dir.value().c_str(), &buf) == 0) { |
82 if (buf.f_type == NFS_SUPER_MAGIC) { | 82 if (buf.f_type == NFS_SUPER_MAGIC) { |
83 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); | 83 scoped_ptr<base::Environment> env(base::Environment::Create()); |
84 const char* use_cache_env_var = "NSS_SDB_USE_CACHE"; | 84 const char* use_cache_env_var = "NSS_SDB_USE_CACHE"; |
85 if (!env->HasEnv(use_cache_env_var)) | 85 if (!env->HasEnv(use_cache_env_var)) |
86 env->SetEnv(use_cache_env_var, "yes"); | 86 env->SetEnv(use_cache_env_var, "yes"); |
87 } | 87 } |
88 } | 88 } |
89 #endif // defined(OS_LINUX) | 89 #endif // defined(OS_LINUX) |
90 } | 90 } |
91 | 91 |
92 // Load nss's built-in root certs. | 92 // Load nss's built-in root certs. |
93 SECMODModule *InitDefaultRootCerts() { | 93 SECMODModule *InitDefaultRootCerts() { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 exploded.millisecond = prxtime.tm_usec / 1000; | 328 exploded.millisecond = prxtime.tm_usec / 1000; |
329 | 329 |
330 return Time::FromUTCExploded(exploded); | 330 return Time::FromUTCExploded(exploded); |
331 } | 331 } |
332 | 332 |
333 PK11SlotInfo* GetDefaultNSSKeySlot() { | 333 PK11SlotInfo* GetDefaultNSSKeySlot() { |
334 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); | 334 return Singleton<NSSInitSingleton>::get()->GetDefaultKeySlot(); |
335 } | 335 } |
336 | 336 |
337 } // namespace base | 337 } // namespace base |
OLD | NEW |