| 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 <dlfcn.h> |
| 7 #include <nss.h> | 8 #include <nss.h> |
| 8 #include <plarena.h> | 9 #include <plarena.h> |
| 9 #include <prerror.h> | 10 #include <prerror.h> |
| 10 #include <prinit.h> | 11 #include <prinit.h> |
| 11 | 12 |
| 12 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 13 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 13 // until NSS 3.12.2 comes out and we update to it. | 14 // until NSS 3.12.2 comes out and we update to it. |
| 14 #define Lock FOO_NSS_Lock | 15 #define Lock FOO_NSS_Lock |
| 15 #include <pk11pub.h> | 16 #include <pk11pub.h> |
| 16 #include <secmod.h> | 17 #include <secmod.h> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (slot) { | 87 if (slot) { |
| 87 if (PK11_NeedUserInit(slot)) | 88 if (PK11_NeedUserInit(slot)) |
| 88 PK11_InitPin(slot, NULL, NULL); | 89 PK11_InitPin(slot, NULL, NULL); |
| 89 PK11_FreeSlot(slot); | 90 PK11_FreeSlot(slot); |
| 90 } | 91 } |
| 91 | 92 |
| 92 root_ = InitDefaultRootCerts(); | 93 root_ = InitDefaultRootCerts(); |
| 93 | 94 |
| 94 NSS_SetDomesticPolicy(); | 95 NSS_SetDomesticPolicy(); |
| 95 | 96 |
| 97 // Use late binding to avoid scary but benign warning |
| 98 // "Symbol `SSL_ImplementedCiphers' has different size in shared object, |
| 99 // consider re-linking" |
| 100 const PRUint16* pSSL_ImplementedCiphers = static_cast<const PRUint16*>( |
| 101 dlsym(RTLD_DEFAULT, "SSL_ImplementedCiphers")); |
| 102 if (pSSL_ImplementedCiphers == NULL) { |
| 103 NOTREACHED() << "Can't get list of supported ciphers"; |
| 104 return; |
| 105 } |
| 106 |
| 96 // Explicitly enable exactly those ciphers with keys of at least 80 bits | 107 // Explicitly enable exactly those ciphers with keys of at least 80 bits |
| 97 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { | 108 for (int i = 0; i < SSL_NumImplementedCiphers; i++) { |
| 98 SSLCipherSuiteInfo info; | 109 SSLCipherSuiteInfo info; |
| 99 if (SSL_GetCipherSuiteInfo(SSL_ImplementedCiphers[i], &info, | 110 if (SSL_GetCipherSuiteInfo(pSSL_ImplementedCiphers[i], &info, |
| 100 sizeof(info)) == SECSuccess) { | 111 sizeof(info)) == SECSuccess) { |
| 101 SSL_CipherPrefSetDefault(SSL_ImplementedCiphers[i], | 112 SSL_CipherPrefSetDefault(pSSL_ImplementedCiphers[i], |
| 102 (info.effectiveKeyBits >= 80)); | 113 (info.effectiveKeyBits >= 80)); |
| 103 } | 114 } |
| 104 } | 115 } |
| 105 | 116 |
| 106 // Enable SSL | 117 // Enable SSL |
| 107 SSL_OptionSetDefault(SSL_SECURITY, PR_TRUE); | 118 SSL_OptionSetDefault(SSL_SECURITY, PR_TRUE); |
| 108 | 119 |
| 109 // All other SSL options are set per-session by SSLClientSocket. | 120 // All other SSL options are set per-session by SSLClientSocket. |
| 110 } | 121 } |
| 111 | 122 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 137 | 148 |
| 138 } // namespace | 149 } // namespace |
| 139 | 150 |
| 140 namespace base { | 151 namespace base { |
| 141 | 152 |
| 142 void EnsureNSSInit() { | 153 void EnsureNSSInit() { |
| 143 Singleton<NSSInitSingleton>::get(); | 154 Singleton<NSSInitSingleton>::get(); |
| 144 } | 155 } |
| 145 | 156 |
| 146 } // namespace base | 157 } // namespace base |
| OLD | NEW |