OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "crypto/nss_util.h" | 5 #include "crypto/nss_util.h" |
6 #include "crypto/nss_util_internal.h" | 6 #include "crypto/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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // Use the system certificate store, so initialize NSS without database. | 445 // Use the system certificate store, so initialize NSS without database. |
446 nodb_init = true; | 446 nodb_init = true; |
447 #endif | 447 #endif |
448 | 448 |
449 if (nodb_init) { | 449 if (nodb_init) { |
450 status = NSS_NoDB_Init(NULL); | 450 status = NSS_NoDB_Init(NULL); |
451 if (status != SECSuccess) { | 451 if (status != SECSuccess) { |
452 LOG(ERROR) << "Error initializing NSS without a persistent " | 452 LOG(ERROR) << "Error initializing NSS without a persistent " |
453 "database: " << GetNSSErrorMessage(); | 453 "database: " << GetNSSErrorMessage(); |
454 } | 454 } |
| 455 #if defined(OS_IOS) |
| 456 root_ = InitDefaultRootCerts(); |
| 457 #endif // defined(OS_IOS) |
455 } else { | 458 } else { |
456 #if defined(USE_NSS) | 459 #if defined(USE_NSS) |
457 FilePath database_dir = GetInitialConfigDirectory(); | 460 FilePath database_dir = GetInitialConfigDirectory(); |
458 if (!database_dir.empty()) { | 461 if (!database_dir.empty()) { |
459 // This duplicates the work which should have been done in | 462 // This duplicates the work which should have been done in |
460 // EarlySetupForNSSInit. However, this function is idempotent so | 463 // EarlySetupForNSSInit. However, this function is idempotent so |
461 // there's no harm done. | 464 // there's no harm done. |
462 UseLocalCacheOfNSSDatabaseIfNFS(database_dir); | 465 UseLocalCacheOfNSSDatabaseIfNFS(database_dir); |
463 | 466 |
464 // Initialize with a persistent database (likely, ~/.pki/nssdb). | 467 // Initialize with a persistent database (likely, ~/.pki/nssdb). |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 534 } |
532 | 535 |
533 SECStatus status = NSS_Shutdown(); | 536 SECStatus status = NSS_Shutdown(); |
534 if (status != SECSuccess) { | 537 if (status != SECSuccess) { |
535 // We VLOG(1) because this failure is relatively harmless (leaking, but | 538 // We VLOG(1) because this failure is relatively harmless (leaking, but |
536 // we're shutting down anyway). | 539 // we're shutting down anyway). |
537 VLOG(1) << "NSS_Shutdown failed; see http://crbug.com/4609"; | 540 VLOG(1) << "NSS_Shutdown failed; see http://crbug.com/4609"; |
538 } | 541 } |
539 } | 542 } |
540 | 543 |
541 #if defined(USE_NSS) | 544 #if defined(USE_NSS) || defined(OS_IOS) |
542 // Load nss's built-in root certs. | 545 // Load nss's built-in root certs. |
543 SECMODModule* InitDefaultRootCerts() { | 546 SECMODModule* InitDefaultRootCerts() { |
544 SECMODModule* root = LoadModule("Root Certs", "libnssckbi.so", NULL); | 547 SECMODModule* root = LoadModule("Root Certs", "libnssckbi.so", NULL); |
545 if (root) | 548 if (root) |
546 return root; | 549 return root; |
547 | 550 |
548 // Aw, snap. Can't find/load root cert shared library. | 551 // Aw, snap. Can't find/load root cert shared library. |
549 // This will make it hard to talk to anybody via https. | 552 // This will make it hard to talk to anybody via https. |
550 NOTREACHED(); | 553 NOTREACHED(); |
551 return NULL; | 554 return NULL; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 | 772 |
770 PK11SlotInfo* GetPublicNSSKeySlot() { | 773 PK11SlotInfo* GetPublicNSSKeySlot() { |
771 return g_nss_singleton.Get().GetPublicNSSKeySlot(); | 774 return g_nss_singleton.Get().GetPublicNSSKeySlot(); |
772 } | 775 } |
773 | 776 |
774 PK11SlotInfo* GetPrivateNSSKeySlot() { | 777 PK11SlotInfo* GetPrivateNSSKeySlot() { |
775 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); | 778 return g_nss_singleton.Get().GetPrivateNSSKeySlot(); |
776 } | 779 } |
777 | 780 |
778 } // namespace crypto | 781 } // namespace crypto |
OLD | NEW |