Chromium Code Reviews| 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. |
|
davidben
2016/01/22 23:57:48
[This implementation completely violates the inter
ryanchung
2016/01/29 23:28:15
Ok.
| |
| 4 | 4 |
| 5 #include "net/socket/ssl_server_socket_nss.h" | 5 #include "net/socket/ssl_server_socket_nss.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <winsock2.h> | 10 #include <winsock2.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #if defined(USE_SYSTEM_SSL) | 13 #if defined(USE_SYSTEM_SSL) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 SSL_ShutdownServerSessionIDCache(); | 70 SSL_ShutdownServerSessionIDCache(); |
| 71 g_nss_server_sockets_init = false; | 71 g_nss_server_sockets_init = false; |
| 72 } | 72 } |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 static base::LazyInstance<NSSSSLServerInitSingleton>::Leaky | 75 static base::LazyInstance<NSSSSLServerInitSingleton>::Leaky |
| 76 g_nss_ssl_server_init_singleton = LAZY_INSTANCE_INITIALIZER; | 76 g_nss_ssl_server_init_singleton = LAZY_INSTANCE_INITIALIZER; |
| 77 | 77 |
| 78 } // namespace | 78 } // namespace |
| 79 | 79 |
| 80 scoped_ptr<SSLServerSocketContext> CreateSSLServerSocketContext( | |
| 81 X509Certificate* certificate, | |
| 82 crypto::RSAPrivateKey* key, | |
|
davidben
2016/01/22 23:57:48
I don't think this compiles. It doesn't match the
ryanchung
2016/01/29 23:28:15
Done.
| |
| 83 const SSLServerConfig& ssl_server_config) { | |
| 84 return new SSLServerSocketContextNSS(certificate, key, ssl_server_config); | |
| 85 } | |
| 86 | |
| 80 void EnableSSLServerSockets() { | 87 void EnableSSLServerSockets() { |
| 81 g_nss_ssl_server_init_singleton.Get(); | 88 g_nss_ssl_server_init_singleton.Get(); |
| 82 } | 89 } |
| 83 | 90 |
| 84 scoped_ptr<SSLServerSocket> CreateSSLServerSocket( | 91 SSLServerSocketContextNSS::SSLServerSocketContextNSS( |
| 85 scoped_ptr<StreamSocket> socket, | 92 scoped_refptr<X509Certificate> certificate, |
|
davidben
2016/01/22 23:57:48
Nit: Unnecessary bouncing on reference counts. X50
ryanchung
2016/01/29 23:28:15
Done.
| |
| 86 X509Certificate* certificate, | |
| 87 const crypto::RSAPrivateKey& key, | 93 const crypto::RSAPrivateKey& key, |
| 88 const SSLServerConfig& ssl_server_config) { | 94 const SSLServerConfig& ssl_server_config) |
| 95 : ssl_server_config_(ssl_server_config), | |
| 96 cert_(certificate), | |
| 97 key_(key.Copy()) { | |
| 98 CHECK(key_); | |
| 99 } | |
| 100 | |
| 101 SSLServerSocketContextNSS::~SSLServerSocketContextNSS() {} | |
| 102 | |
| 103 scoped_ptr<SSLServerSocket> SSLServerSocketContextNSS::CreateSSLServerSocket( | |
| 104 scoped_ptr<StreamSocket> socket) { | |
| 89 DCHECK(g_nss_server_sockets_init) << "EnableSSLServerSockets() has not been" | 105 DCHECK(g_nss_server_sockets_init) << "EnableSSLServerSockets() has not been" |
| 90 << " called yet!"; | 106 << " called yet!"; |
| 91 | 107 |
| 92 return scoped_ptr<SSLServerSocket>(new SSLServerSocketNSS( | 108 return scoped_ptr<SSLServerSocket>(new SSLServerSocketNSS( |
| 93 std::move(socket), certificate, key, ssl_server_config)); | 109 std::move(socket), cert_.get(), *key_, ssl_server_config_)); |
| 94 } | 110 } |
| 95 | 111 |
| 96 SSLServerSocketNSS::SSLServerSocketNSS( | 112 SSLServerSocketNSS::SSLServerSocketNSS( |
| 97 scoped_ptr<StreamSocket> transport_socket, | 113 scoped_ptr<StreamSocket> transport_socket, |
| 98 scoped_refptr<X509Certificate> cert, | 114 scoped_refptr<X509Certificate> cert, |
| 99 const crypto::RSAPrivateKey& key, | 115 const crypto::RSAPrivateKey& key, |
| 100 const SSLServerConfig& ssl_server_config) | 116 const SSLServerConfig& ssl_server_config) |
| 101 : transport_send_busy_(false), | 117 : transport_send_busy_(false), |
| 102 transport_recv_busy_(false), | 118 transport_recv_busy_(false), |
| 103 user_read_buf_len_(0), | 119 user_read_buf_len_(0), |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 847 // initializes the NSS base library. | 863 // initializes the NSS base library. |
| 848 EnsureNSSSSLInit(); | 864 EnsureNSSSSLInit(); |
| 849 if (!NSS_IsInitialized()) | 865 if (!NSS_IsInitialized()) |
| 850 return ERR_UNEXPECTED; | 866 return ERR_UNEXPECTED; |
| 851 | 867 |
| 852 EnableSSLServerSockets(); | 868 EnableSSLServerSockets(); |
| 853 return OK; | 869 return OK; |
| 854 } | 870 } |
| 855 | 871 |
| 856 } // namespace net | 872 } // namespace net |
| OLD | NEW |