OLD | NEW |
---|---|
1 // Copyright (c) 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/nfs_fs.h> | 17 #include <linux/nfs_fs.h> |
18 #include <sys/vfs.h> | 18 #include <sys/vfs.h> |
19 #endif | 19 #endif |
20 | 20 |
21 #include "base/environment.h" | 21 #include "base/environment.h" |
22 #include "base/file_path.h" | |
22 #include "base/file_util.h" | 23 #include "base/file_util.h" |
23 #include "base/lazy_instance.h" | 24 #include "base/lazy_instance.h" |
24 #include "base/logging.h" | 25 #include "base/logging.h" |
26 #include "base/native_library.h" | |
25 #include "base/scoped_ptr.h" | 27 #include "base/scoped_ptr.h" |
26 #include "base/stringprintf.h" | 28 #include "base/stringprintf.h" |
27 #include "base/threading/thread_restrictions.h" | 29 #include "base/threading/thread_restrictions.h" |
28 | 30 |
29 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not | 31 // USE_NSS means we use NSS for everything crypto-related. If USE_NSS is not |
30 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't | 32 // defined, such as on Mac and Windows, we use NSS for SSL only -- we don't |
31 // use NSS for crypto or certificate verification, and we don't use the NSS | 33 // use NSS for crypto or certificate verification, and we don't use the NSS |
32 // certificate and key databases. | 34 // certificate and key databases. |
33 #if defined(USE_NSS) | 35 #if defined(USE_NSS) |
34 #include "base/crypto/crypto_module_blocking_password_delegate.h" | 36 #include "base/crypto/crypto_module_blocking_password_delegate.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 | 397 |
396 void ForceNSSNoDBInit() { | 398 void ForceNSSNoDBInit() { |
397 NSSInitSingleton::ForceNoDBInit(); | 399 NSSInitSingleton::ForceNoDBInit(); |
398 } | 400 } |
399 | 401 |
400 void DisableNSSForkCheck() { | 402 void DisableNSSForkCheck() { |
401 scoped_ptr<Environment> env(Environment::Create()); | 403 scoped_ptr<Environment> env(Environment::Create()); |
402 env->SetVar("NSS_STRICT_NOFORK", "DISABLED"); | 404 env->SetVar("NSS_STRICT_NOFORK", "DISABLED"); |
403 } | 405 } |
404 | 406 |
407 void LoadNSSLibraries() { | |
408 // NSS libraries are linked dynamically on Linux so do this only on Linux. | |
409 #if defined(OS_LINUX) | |
410 FilePath module_path("/usr/lib/nss"); | |
wtc
2011/03/16 19:00:52
"/usr/lib/nss" is specific to Debian and its deriv
| |
411 base::LoadNativeLibrary(module_path.Append("libsoftokn3.so")); | |
412 base::LoadNativeLibrary(module_path.Append("libfreebl3.so")); | |
413 #endif | |
414 } | |
415 | |
405 bool CheckNSSVersion(const char* version) { | 416 bool CheckNSSVersion(const char* version) { |
406 return !!NSS_VersionCheck(version); | 417 return !!NSS_VersionCheck(version); |
407 } | 418 } |
408 | 419 |
409 #if defined(USE_NSS) | 420 #if defined(USE_NSS) |
410 bool OpenTestNSSDB(const FilePath& path, const char* description) { | 421 bool OpenTestNSSDB(const FilePath& path, const char* description) { |
411 return g_nss_singleton.Get().OpenTestNSSDB(path, description); | 422 return g_nss_singleton.Get().OpenTestNSSDB(path, description); |
412 } | 423 } |
413 | 424 |
414 void CloseTestNSSDB() { | 425 void CloseTestNSSDB() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
456 exploded.millisecond = prxtime.tm_usec / 1000; | 467 exploded.millisecond = prxtime.tm_usec / 1000; |
457 | 468 |
458 return Time::FromUTCExploded(exploded); | 469 return Time::FromUTCExploded(exploded); |
459 } | 470 } |
460 | 471 |
461 PK11SlotInfo* GetDefaultNSSKeySlot() { | 472 PK11SlotInfo* GetDefaultNSSKeySlot() { |
462 return g_nss_singleton.Get().GetDefaultKeySlot(); | 473 return g_nss_singleton.Get().GetDefaultKeySlot(); |
463 } | 474 } |
464 | 475 |
465 } // namespace base | 476 } // namespace base |
OLD | NEW |