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 "net/socket/ssl_server_socket_nss.h" | 5 #include "net/socket/ssl_server_socket_nss.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 bool g_nss_server_sockets_init = false; | 55 bool g_nss_server_sockets_init = false; |
56 | 56 |
57 class NSSSSLServerInitSingleton { | 57 class NSSSSLServerInitSingleton { |
58 public: | 58 public: |
59 NSSSSLServerInitSingleton() { | 59 NSSSSLServerInitSingleton() { |
60 EnsureNSSSSLInit(); | 60 EnsureNSSSSLInit(); |
61 | 61 |
62 SSL_ConfigServerSessionIDCache(1024, 5, 5, NULL); | 62 SSL_ConfigServerSessionIDCache(64, 28800, 28800, NULL); |
63 g_nss_server_sockets_init = true; | 63 g_nss_server_sockets_init = true; |
64 } | 64 } |
65 | 65 |
66 ~NSSSSLServerInitSingleton() { | 66 ~NSSSSLServerInitSingleton() { |
67 SSL_ShutdownServerSessionIDCache(); | 67 SSL_ShutdownServerSessionIDCache(); |
68 g_nss_server_sockets_init = false; | 68 g_nss_server_sockets_init = false; |
69 } | 69 } |
70 }; | 70 }; |
71 | 71 |
72 static base::LazyInstance<NSSSSLServerInitSingleton> | 72 static base::LazyInstance<NSSSSLServerInitSingleton> |
73 g_nss_ssl_server_init_singleton = LAZY_INSTANCE_INITIALIZER; | 73 g_nss_ssl_server_init_singleton = LAZY_INSTANCE_INITIALIZER; |
74 | 74 |
75 } // namespace | 75 } // namespace |
76 | 76 |
77 void EnableSSLServerSockets() { | 77 void EnableSSLServerSockets() { |
78 g_nss_ssl_server_init_singleton.Get(); | 78 g_nss_ssl_server_init_singleton.Get(); |
79 } | 79 } |
80 | 80 |
81 scoped_ptr<SSLServerSocket> CreateSSLServerSocket( | 81 scoped_ptr<SSLServerSocket> CreateSSLServerSocket( |
82 scoped_ptr<StreamSocket> socket, | 82 scoped_ptr<StreamSocket> socket, |
83 X509Certificate* cert, | 83 X509Certificate* cert, |
84 crypto::RSAPrivateKey* key, | 84 crypto::RSAPrivateKey* key, |
85 const SSLConfig& ssl_config) { | 85 const SSLConfig& ssl_config) { |
86 DCHECK(g_nss_server_sockets_init) << "EnableSSLServerSockets() has not been" | 86 DCHECK(g_nss_server_sockets_init) << "EnableSSLServerSockets() has not been" |
87 << "called yet!"; | 87 << " called yet!"; |
88 | 88 |
89 return scoped_ptr<SSLServerSocket>( | 89 return scoped_ptr<SSLServerSocket>( |
90 new SSLServerSocketNSS(socket.Pass(), cert, key, ssl_config)); | 90 new SSLServerSocketNSS(socket.Pass(), cert, key, ssl_config)); |
91 } | 91 } |
92 | 92 |
93 SSLServerSocketNSS::SSLServerSocketNSS( | 93 SSLServerSocketNSS::SSLServerSocketNSS( |
94 scoped_ptr<StreamSocket> transport_socket, | 94 scoped_ptr<StreamSocket> transport_socket, |
95 scoped_refptr<X509Certificate> cert, | 95 scoped_refptr<X509Certificate> cert, |
96 crypto::RSAPrivateKey* key, | 96 crypto::RSAPrivateKey* key, |
97 const SSLConfig& ssl_config) | 97 const SSLConfig& ssl_config) |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 // initializes the NSS base library. | 830 // initializes the NSS base library. |
831 EnsureNSSSSLInit(); | 831 EnsureNSSSSLInit(); |
832 if (!NSS_IsInitialized()) | 832 if (!NSS_IsInitialized()) |
833 return ERR_UNEXPECTED; | 833 return ERR_UNEXPECTED; |
834 | 834 |
835 EnableSSLServerSockets(); | 835 EnableSSLServerSockets(); |
836 return OK; | 836 return OK; |
837 } | 837 } |
838 | 838 |
839 } // namespace net | 839 } // namespace net |
OLD | NEW |