| 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 <prerror.h> |
| 10 #include <prinit.h> | 10 #include <prinit.h> |
| 11 | 11 |
| 12 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 12 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 13 // 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. |
| 14 #define Lock FOO_NSS_Lock | 14 #define Lock FOO_NSS_Lock |
| 15 #include <pk11pub.h> |
| 15 #include <secmod.h> | 16 #include <secmod.h> |
| 16 #include <ssl.h> | 17 #include <ssl.h> |
| 17 #undef Lock | 18 #undef Lock |
| 18 | 19 |
| 19 #include "base/file_util.h" | 20 #include "base/file_util.h" |
| 20 #include "base/logging.h" | 21 #include "base/logging.h" |
| 21 #include "base/singleton.h" | 22 #include "base/singleton.h" |
| 22 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 72 } |
| 72 if (status != SECSuccess) { | 73 if (status != SECSuccess) { |
| 73 char buffer[513] = "Couldn't retrieve error"; | 74 char buffer[513] = "Couldn't retrieve error"; |
| 74 PRInt32 err_length = PR_GetErrorTextLength(); | 75 PRInt32 err_length = PR_GetErrorTextLength(); |
| 75 if (err_length > 0 && static_cast<size_t>(err_length) < sizeof(buffer)) | 76 if (err_length > 0 && static_cast<size_t>(err_length) < sizeof(buffer)) |
| 76 PR_GetErrorText(buffer); | 77 PR_GetErrorText(buffer); |
| 77 | 78 |
| 78 NOTREACHED() << "Error initializing NSS: " << buffer; | 79 NOTREACHED() << "Error initializing NSS: " << buffer; |
| 79 } | 80 } |
| 80 | 81 |
| 82 // If we haven't initialized the password for the NSS databases, |
| 83 // initialize an empty-string password so that we don't need to |
| 84 // log in. |
| 85 PK11SlotInfo* slot = PK11_GetInternalKeySlot(); |
| 86 if (slot) { |
| 87 if (PK11_NeedUserInit(slot)) |
| 88 PK11_InitPin(slot, NULL, NULL); |
| 89 PK11_FreeSlot(slot); |
| 90 } |
| 91 |
| 81 root_ = InitDefaultRootCerts(); | 92 root_ = InitDefaultRootCerts(); |
| 82 | 93 |
| 83 NSS_SetDomesticPolicy(); | 94 NSS_SetDomesticPolicy(); |
| 84 | 95 |
| 85 // Explicitly enable exactly those ciphers with keys of at least 80 bits | 96 // Explicitly enable exactly those ciphers with keys of at least 80 bits |
| 86 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { | 97 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { |
| 87 SSLCipherSuiteInfo info; | 98 SSLCipherSuiteInfo info; |
| 88 if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info, | 99 if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info, |
| 89 sizeof(info)) == SECSuccess) { | 100 sizeof(info)) == SECSuccess) { |
| 90 SSL_CipherPrefSetDefault(SSL_ImplementedCiphers[i], | 101 SSL_CipherPrefSetDefault(SSL_ImplementedCiphers[i], |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 137 |
| 127 } // namespace | 138 } // namespace |
| 128 | 139 |
| 129 namespace base { | 140 namespace base { |
| 130 | 141 |
| 131 void EnsureNSSInit() { | 142 void EnsureNSSInit() { |
| 132 Singleton<NSSInitSingleton>::get(); | 143 Singleton<NSSInitSingleton>::get(); |
| 133 } | 144 } |
| 134 | 145 |
| 135 } // namespace base | 146 } // namespace base |
| OLD | NEW |