| 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_impl.h" | 5 #include "net/socket/ssl_server_socket_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool WasAlpnNegotiated() const override; | 97 bool WasAlpnNegotiated() const override; |
| 98 NextProto GetNegotiatedProtocol() const override; | 98 NextProto GetNegotiatedProtocol() const override; |
| 99 bool GetSSLInfo(SSLInfo* ssl_info) override; | 99 bool GetSSLInfo(SSLInfo* ssl_info) override; |
| 100 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 100 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 101 void ClearConnectionAttempts() override {} | 101 void ClearConnectionAttempts() override {} |
| 102 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} | 102 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
| 103 int64_t GetTotalReceivedBytes() const override; | 103 int64_t GetTotalReceivedBytes() const override; |
| 104 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg); | 104 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg); |
| 105 | 105 |
| 106 // SocketBIOAdapter::Delegate implementation. | 106 // SocketBIOAdapter::Delegate implementation. |
| 107 void OnReadReady() override; | 107 void OnReadReady(int result) override; |
| 108 void OnWriteReady() override; | 108 void OnWriteReady(int result) override; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 enum State { | 111 enum State { |
| 112 STATE_NONE, | 112 STATE_NONE, |
| 113 STATE_HANDSHAKE, | 113 STATE_HANDSHAKE, |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 void OnHandshakeIOComplete(int result); | 116 void OnHandshakeIOComplete(int result); |
| 117 | 117 |
| 118 int DoPayloadRead(); | 118 int DoPayloadRead(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 363 } |
| 364 | 364 |
| 365 void SSLServerSocketImpl::GetConnectionAttempts(ConnectionAttempts* out) const { | 365 void SSLServerSocketImpl::GetConnectionAttempts(ConnectionAttempts* out) const { |
| 366 out->clear(); | 366 out->clear(); |
| 367 } | 367 } |
| 368 | 368 |
| 369 int64_t SSLServerSocketImpl::GetTotalReceivedBytes() const { | 369 int64_t SSLServerSocketImpl::GetTotalReceivedBytes() const { |
| 370 return transport_socket_->GetTotalReceivedBytes(); | 370 return transport_socket_->GetTotalReceivedBytes(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 void SSLServerSocketImpl::OnReadReady() { | 373 void SSLServerSocketImpl::OnReadReady(int result) { |
| 374 if (next_handshake_state_ == STATE_HANDSHAKE) { | 374 if (next_handshake_state_ == STATE_HANDSHAKE) { |
| 375 // In handshake phase. The parameter to OnHandshakeIOComplete is unused. | 375 // In handshake phase. The parameter to OnHandshakeIOComplete is unused. |
| 376 OnHandshakeIOComplete(OK); | 376 OnHandshakeIOComplete(OK); |
| 377 return; | 377 return; |
| 378 } | 378 } |
| 379 | 379 |
| 380 // BoringSSL does not support renegotiation as a server, so the only other | 380 // BoringSSL does not support renegotiation as a server, so the only other |
| 381 // operation blocked on Read is DoPayloadRead. | 381 // operation blocked on Read is DoPayloadRead. |
| 382 if (!user_read_buf_) | 382 if (!user_read_buf_) |
| 383 return; | 383 return; |
| 384 | 384 |
| 385 int rv = DoPayloadRead(); | 385 int rv = DoPayloadRead(); |
| 386 if (rv != ERR_IO_PENDING) | 386 if (rv != ERR_IO_PENDING) |
| 387 DoReadCallback(rv); | 387 DoReadCallback(rv); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void SSLServerSocketImpl::OnWriteReady() { | 390 void SSLServerSocketImpl::OnWriteReady(int result) { |
| 391 if (next_handshake_state_ == STATE_HANDSHAKE) { | 391 if (next_handshake_state_ == STATE_HANDSHAKE) { |
| 392 // In handshake phase. The parameter to OnHandshakeIOComplete is unused. | 392 // In handshake phase. The parameter to OnHandshakeIOComplete is unused. |
| 393 OnHandshakeIOComplete(OK); | 393 OnHandshakeIOComplete(OK); |
| 394 return; | 394 return; |
| 395 } | 395 } |
| 396 | 396 |
| 397 // BoringSSL does not support renegotiation as a server, so the only other | 397 // BoringSSL does not support renegotiation as a server, so the only other |
| 398 // operation blocked on Read is DoPayloadWrite. | 398 // operation blocked on Read is DoPayloadWrite. |
| 399 if (!user_write_buf_) | 399 if (!user_write_buf_) |
| 400 return; | 400 return; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 SSLServerContextImpl::~SSLServerContextImpl() {} | 730 SSLServerContextImpl::~SSLServerContextImpl() {} |
| 731 | 731 |
| 732 std::unique_ptr<SSLServerSocket> SSLServerContextImpl::CreateSSLServerSocket( | 732 std::unique_ptr<SSLServerSocket> SSLServerContextImpl::CreateSSLServerSocket( |
| 733 std::unique_ptr<StreamSocket> socket) { | 733 std::unique_ptr<StreamSocket> socket) { |
| 734 bssl::UniquePtr<SSL> ssl(SSL_new(ssl_ctx_.get())); | 734 bssl::UniquePtr<SSL> ssl(SSL_new(ssl_ctx_.get())); |
| 735 return std::unique_ptr<SSLServerSocket>( | 735 return std::unique_ptr<SSLServerSocket>( |
| 736 new SSLServerSocketImpl(std::move(socket), std::move(ssl))); | 736 new SSLServerSocketImpl(std::move(socket), std::move(ssl))); |
| 737 } | 737 } |
| 738 | 738 |
| 739 } // namespace net | 739 } // namespace net |
| OLD | NEW |