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 | 8 |
| 9 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 10 // until NSS 3.12.2 comes out and we update to it. |
| 11 #define Lock FOO_NSS_Lock |
| 12 #include <ssl.h> |
| 13 #undef Lock |
| 14 |
9 #include "base/logging.h" | 15 #include "base/logging.h" |
10 #include "base/singleton.h" | 16 #include "base/singleton.h" |
11 | 17 |
12 namespace { | 18 namespace { |
13 | 19 |
14 class NSSInitSingleton { | 20 class NSSInitSingleton { |
15 public: | 21 public: |
16 NSSInitSingleton() { | 22 NSSInitSingleton() { |
17 CHECK(NSS_NoDB_Init(".") == SECSuccess); | 23 CHECK(NSS_NoDB_Init(".") == SECSuccess); |
| 24 // Enable ciphers |
| 25 NSS_SetDomesticPolicy(); |
| 26 // Enable SSL |
| 27 SSL_OptionSetDefault(SSL_SECURITY, PR_TRUE); |
18 } | 28 } |
19 | 29 |
20 ~NSSInitSingleton() { | 30 ~NSSInitSingleton() { |
| 31 // Have to clear the cache, or NSS_Shutdown fails with SEC_ERROR_BUSY |
| 32 SSL_ClearSessionCache(); |
| 33 |
21 SECStatus status = NSS_Shutdown(); | 34 SECStatus status = NSS_Shutdown(); |
22 DCHECK(status == SECSuccess); | 35 DCHECK(status == SECSuccess); |
23 } | 36 } |
24 }; | 37 }; |
25 | 38 |
26 } // namespace | 39 } // namespace |
27 | 40 |
28 namespace base { | 41 namespace base { |
29 | 42 |
30 void EnsureNSSInit() { | 43 void EnsureNSSInit() { |
31 Singleton<NSSInitSingleton>::get(); | 44 Singleton<NSSInitSingleton>::get(); |
32 } | 45 } |
33 | 46 |
34 } // namespace base | 47 } // namespace base |
OLD | NEW |