| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 <nss.h> | 7 #include <nss.h> |
| 8 #include <plarena.h> | 8 #include <plarena.h> |
| 9 #include <prerror.h> |
| 9 #include <prinit.h> | 10 #include <prinit.h> |
| 10 | 11 |
| 11 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 12 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 12 // until NSS 3.12.2 comes out and we update to it. | 13 // until NSS 3.12.2 comes out and we update to it. |
| 13 #define Lock FOO_NSS_Lock | 14 #define Lock FOO_NSS_Lock |
| 14 #include <secmod.h> | 15 #include <secmod.h> |
| 15 #include <ssl.h> | 16 #include <ssl.h> |
| 16 #undef Lock | 17 #undef Lock |
| 17 | 18 |
| 18 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 | 34 |
| 34 // Aw, snap. Can't find/load root cert shared library. | 35 // Aw, snap. Can't find/load root cert shared library. |
| 35 // This will make it hard to talk to anybody via https. | 36 // This will make it hard to talk to anybody via https. |
| 36 NOTREACHED(); | 37 NOTREACHED(); |
| 37 return NULL; | 38 return NULL; |
| 38 } | 39 } |
| 39 | 40 |
| 40 class NSSInitSingleton { | 41 class NSSInitSingleton { |
| 41 public: | 42 public: |
| 42 NSSInitSingleton() { | 43 NSSInitSingleton() { |
| 44 // Initialize without using a persistant database (e.g. ~/.netscape) |
| 45 SECStatus status = NSS_NoDB_Init("."); |
| 46 if (status != SECSuccess) { |
| 47 char buffer[513] = "Couldn't retrieve error"; |
| 48 PRInt32 err_length = PR_GetErrorTextLength(); |
| 49 if (err_length > 0 && size_t(err_length) < sizeof(buffer)) |
| 50 PR_GetErrorText(buffer); |
| 43 | 51 |
| 44 // Initialize without using a persistant database (e.g. ~/.netscape) | 52 NOTREACHED() << "Error calling NSS_NoDB_Init: " << buffer; |
| 45 CHECK(NSS_NoDB_Init(".") == SECSuccess); | 53 } |
| 46 | 54 |
| 47 root_ = InitDefaultRootCerts(); | 55 root_ = InitDefaultRootCerts(); |
| 48 | 56 |
| 49 NSS_SetDomesticPolicy(); | 57 NSS_SetDomesticPolicy(); |
| 50 | 58 |
| 51 // Explicitly enable exactly those ciphers with keys of at least 80 bits | 59 // Explicitly enable exactly those ciphers with keys of at least 80 bits |
| 52 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { | 60 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { |
| 53 SSLCipherSuiteInfo info; | 61 SSLCipherSuiteInfo info; |
| 54 if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info, | 62 if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info, |
| 55 sizeof(info)) == SECSuccess) { | 63 sizeof(info)) == SECSuccess) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 100 |
| 93 } // namespace | 101 } // namespace |
| 94 | 102 |
| 95 namespace base { | 103 namespace base { |
| 96 | 104 |
| 97 void EnsureNSSInit() { | 105 void EnsureNSSInit() { |
| 98 Singleton<NSSInitSingleton>::get(); | 106 Singleton<NSSInitSingleton>::get(); |
| 99 } | 107 } |
| 100 | 108 |
| 101 } // namespace base | 109 } // namespace base |
| OLD | NEW |