Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: net/socket/ssl_server_socket_nss.cc

Issue 7054010: Update SSLServerSocket to provide the net::StreamSocket interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the SSLServerSocketOpenSSL stub for these changes. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 27 matching lines...) Expand all
38 #include "net/ocsp/nss_ocsp.h" 38 #include "net/ocsp/nss_ocsp.h"
39 #include "net/socket/nss_ssl_util.h" 39 #include "net/socket/nss_ssl_util.h"
40 #include "net/socket/ssl_error_params.h" 40 #include "net/socket/ssl_error_params.h"
41 41
42 static const int kRecvBufferSize = 4096; 42 static const int kRecvBufferSize = 4096;
43 43
44 #define GotoState(s) next_handshake_state_ = s 44 #define GotoState(s) next_handshake_state_ = s
45 45
46 namespace net { 46 namespace net {
47 47
48 SSLServerSocket* CreateSSLServerSocket( 48 StreamSocket* CreateSSLServerSocket(
49 Socket* socket, X509Certificate* cert, crypto::RSAPrivateKey* key, 49 StreamSocket* socket,
50 X509Certificate* cert,
51 const crypto::RSAPrivateKey* key,
50 const SSLConfig& ssl_config) { 52 const SSLConfig& ssl_config) {
51 return new SSLServerSocketNSS(socket, cert, key, ssl_config); 53 return new SSLServerSocketNSS(socket, cert, key, ssl_config);
52 } 54 }
53 55
54 SSLServerSocketNSS::SSLServerSocketNSS( 56 SSLServerSocketNSS::SSLServerSocketNSS(
55 Socket* transport_socket, 57 StreamSocket* transport_socket,
56 scoped_refptr<X509Certificate> cert, 58 scoped_refptr<X509Certificate> cert,
57 crypto::RSAPrivateKey* key, 59 const crypto::RSAPrivateKey* key,
58 const SSLConfig& ssl_config) 60 const SSLConfig& ssl_config)
59 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_( 61 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_(
60 this, &SSLServerSocketNSS::BufferSendComplete)), 62 this, &SSLServerSocketNSS::BufferSendComplete)),
61 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_( 63 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_(
62 this, &SSLServerSocketNSS::BufferRecvComplete)), 64 this, &SSLServerSocketNSS::BufferRecvComplete)),
63 transport_send_busy_(false), 65 transport_send_busy_(false),
64 transport_recv_busy_(false), 66 transport_recv_busy_(false),
65 user_accept_callback_(NULL), 67 user_accept_callback_(NULL),
66 user_read_callback_(NULL), 68 user_read_callback_(NULL),
67 user_write_callback_(NULL), 69 user_write_callback_(NULL),
(...skipping 15 matching lines...) Expand all
83 CHECK(key_.get()); 85 CHECK(key_.get());
84 } 86 }
85 87
86 SSLServerSocketNSS::~SSLServerSocketNSS() { 88 SSLServerSocketNSS::~SSLServerSocketNSS() {
87 if (nss_fd_ != NULL) { 89 if (nss_fd_ != NULL) {
88 PR_Close(nss_fd_); 90 PR_Close(nss_fd_);
89 nss_fd_ = NULL; 91 nss_fd_ = NULL;
90 } 92 }
91 } 93 }
92 94
93 int SSLServerSocketNSS::Accept(CompletionCallback* callback) { 95 int SSLServerSocketNSS::Connect(CompletionCallback* callback) {
94 net_log_.BeginEvent(NetLog::TYPE_SSL_ACCEPT, NULL); 96 net_log_.BeginEvent(NetLog::TYPE_SSL_ACCEPT, NULL);
95 97
96 int rv = Init(); 98 int rv = Init();
97 if (rv != OK) { 99 if (rv != OK) {
98 LOG(ERROR) << "Failed to initialize NSS"; 100 LOG(ERROR) << "Failed to initialize NSS";
99 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_ACCEPT, rv); 101 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_ACCEPT, rv);
100 return rv; 102 return rv;
101 } 103 }
102 104
103 rv = InitializeSSLOptions(); 105 rv = InitializeSSLOptions();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 162
161 if (rv == ERR_IO_PENDING) { 163 if (rv == ERR_IO_PENDING) {
162 user_write_callback_ = callback; 164 user_write_callback_ = callback;
163 } else { 165 } else {
164 user_write_buf_ = NULL; 166 user_write_buf_ = NULL;
165 user_write_buf_len_ = 0; 167 user_write_buf_len_ = 0;
166 } 168 }
167 return rv; 169 return rv;
168 } 170 }
169 171
172 bool SSLServerSocketNSS::IsConnected() const {
173 return completed_handshake_;
174 }
175
176 void SSLServerSocketNSS::Disconnect() {
177 transport_socket_->Disconnect();
178 }
179
180 bool SSLServerSocketNSS::IsConnectedAndIdle() const {
181 return completed_handshake_ && transport_socket_->IsConnectedAndIdle();
182 }
183
184 int SSLServerSocketNSS::GetPeerAddress(AddressList* address) const {
185 if (!IsConnected())
186 return ERR_SOCKET_NOT_CONNECTED;
187 return transport_socket_->GetPeerAddress(address);
188 }
189
190 int SSLServerSocketNSS::GetLocalAddress(IPEndPoint* address) const {
191 if (!IsConnected())
192 return ERR_SOCKET_NOT_CONNECTED;
193 return transport_socket_->GetLocalAddress(address);
194 }
195
196 const BoundNetLog& SSLServerSocketNSS::NetLog() const {
197 return net_log_;
198 }
199
200 void SSLServerSocketNSS::SetSubresourceSpeculation() {
201 transport_socket_->SetSubresourceSpeculation();
202 }
203
204 void SSLServerSocketNSS::SetOmniboxSpeculation() {
205 transport_socket_->SetOmniboxSpeculation();
206 }
207
208 bool SSLServerSocketNSS::WasEverUsed() const {
209 return transport_socket_->WasEverUsed();
210 }
211
212 bool SSLServerSocketNSS::UsingTCPFastOpen() const {
213 return transport_socket_->UsingTCPFastOpen();
214 }
215
170 bool SSLServerSocketNSS::SetReceiveBufferSize(int32 size) { 216 bool SSLServerSocketNSS::SetReceiveBufferSize(int32 size) {
171 return false; 217 return false;
172 } 218 }
173 219
174 bool SSLServerSocketNSS::SetSendBufferSize(int32 size) { 220 bool SSLServerSocketNSS::SetSendBufferSize(int32 size) {
175 return false; 221 return false;
176 } 222 }
177 223
Sergey Ulanov 2011/05/31 22:19:49 nit: remove this empty line.
Wez 2011/05/31 22:41:54 Done.
224
178 int SSLServerSocketNSS::InitializeSSLOptions() { 225 int SSLServerSocketNSS::InitializeSSLOptions() {
179 // Transport connected, now hook it up to nss 226 // Transport connected, now hook it up to nss
180 // TODO(port): specify rx and tx buffer sizes separately 227 // TODO(port): specify rx and tx buffer sizes separately
181 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize); 228 nss_fd_ = memio_CreateIOLayer(kRecvBufferSize);
182 if (nss_fd_ == NULL) { 229 if (nss_fd_ == NULL) {
183 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code. 230 return ERR_OUT_OF_MEMORY; // TODO(port): map NSPR error code.
184 } 231 }
185 232
186 // Grab pointer to buffers 233 // Grab pointer to buffers
187 nss_bufs_ = memio_GetSecret(nss_fd_); 234 nss_bufs_ = memio_GetSecret(nss_fd_);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop 723 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop
677 // by MessageLoopForIO::current(). 724 // by MessageLoopForIO::current().
678 // X509Certificate::Verify() runs on a worker thread of CertVerifier. 725 // X509Certificate::Verify() runs on a worker thread of CertVerifier.
679 EnsureOCSPInit(); 726 EnsureOCSPInit();
680 #endif 727 #endif
681 728
682 return OK; 729 return OK;
683 } 730 }
684 731
685 } // namespace net 732 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698