| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ | 5 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ |
| 6 #define NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ | 6 #define NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/log/net_log.h" | 14 #include "net/log/net_log.h" |
| 15 #include "net/socket/ssl_server_socket.h" | 15 #include "net/socket/ssl_server_socket.h" |
| 16 #include "net/ssl/ssl_server_config.h" | 16 #include "net/ssl/ssl_server_config.h" |
| 17 | 17 |
| 18 // Avoid including misc OpenSSL headers, i.e.: | 18 // Avoid including misc OpenSSL headers, i.e.: |
| 19 // <openssl/bio.h> | 19 // <openssl/bio.h> |
| 20 typedef struct bio_st BIO; | 20 typedef struct bio_st BIO; |
| 21 // <openssl/ssl.h> | 21 // <openssl/ssl.h> |
| 22 typedef struct ssl_st SSL; | 22 typedef struct ssl_st SSL; |
| 23 typedef struct x509_store_ctx_st X509_STORE_CTX; |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| 25 | 26 |
| 26 class SSLInfo; | 27 class SSLInfo; |
| 27 | 28 |
| 28 class SSLServerSocketOpenSSL : public SSLServerSocket { | 29 class SSLServerSocketOpenSSL : public SSLServerSocket { |
| 29 public: | 30 public: |
| 30 // See comments on CreateSSLServerSocket for details of how these | 31 // See comments on CreateSSLServerSocket for details of how these |
| 31 // parameters are used. | 32 // parameters are used. |
| 32 SSLServerSocketOpenSSL(scoped_ptr<StreamSocket> socket, | 33 SSLServerSocketOpenSSL(scoped_ptr<StreamSocket> socket, |
| 33 scoped_refptr<X509Certificate> certificate, | 34 scoped_refptr<X509Certificate> certificate, |
| 34 const crypto::RSAPrivateKey& key, | 35 const crypto::RSAPrivateKey& key, |
| 35 const SSLServerConfig& ssl_config); | 36 const SSLServerConfig& ssl_server_config); |
| 36 ~SSLServerSocketOpenSSL() override; | 37 ~SSLServerSocketOpenSSL() override; |
| 37 | 38 |
| 38 // SSLServerSocket interface. | 39 // SSLServerSocket interface. |
| 39 int Handshake(const CompletionCallback& callback) override; | 40 int Handshake(const CompletionCallback& callback) override; |
| 40 | 41 |
| 41 // SSLSocket interface. | 42 // SSLSocket interface. |
| 42 int ExportKeyingMaterial(const base::StringPiece& label, | 43 int ExportKeyingMaterial(const base::StringPiece& label, |
| 43 bool has_context, | 44 bool has_context, |
| 44 const base::StringPiece& context, | 45 const base::StringPiece& context, |
| 45 unsigned char* out, | 46 unsigned char* out, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 99 |
| 99 int DoHandshakeLoop(int last_io_result); | 100 int DoHandshakeLoop(int last_io_result); |
| 100 int DoReadLoop(int result); | 101 int DoReadLoop(int result); |
| 101 int DoWriteLoop(int result); | 102 int DoWriteLoop(int result); |
| 102 int DoHandshake(); | 103 int DoHandshake(); |
| 103 void DoHandshakeCallback(int result); | 104 void DoHandshakeCallback(int result); |
| 104 void DoReadCallback(int result); | 105 void DoReadCallback(int result); |
| 105 void DoWriteCallback(int result); | 106 void DoWriteCallback(int result); |
| 106 | 107 |
| 107 int Init(); | 108 int Init(); |
| 109 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg); |
| 108 | 110 |
| 109 // Members used to send and receive buffer. | 111 // Members used to send and receive buffer. |
| 110 bool transport_send_busy_; | 112 bool transport_send_busy_; |
| 111 bool transport_recv_busy_; | 113 bool transport_recv_busy_; |
| 112 bool transport_recv_eof_; | 114 bool transport_recv_eof_; |
| 113 | 115 |
| 114 scoped_refptr<DrainableIOBuffer> send_buffer_; | 116 scoped_refptr<DrainableIOBuffer> send_buffer_; |
| 115 scoped_refptr<IOBuffer> recv_buffer_; | 117 scoped_refptr<IOBuffer> recv_buffer_; |
| 116 | 118 |
| 117 BoundNetLog net_log_; | 119 BoundNetLog net_log_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 133 int transport_write_error_; | 135 int transport_write_error_; |
| 134 | 136 |
| 135 // OpenSSL stuff | 137 // OpenSSL stuff |
| 136 SSL* ssl_; | 138 SSL* ssl_; |
| 137 BIO* transport_bio_; | 139 BIO* transport_bio_; |
| 138 | 140 |
| 139 // StreamSocket for sending and receiving data. | 141 // StreamSocket for sending and receiving data. |
| 140 scoped_ptr<StreamSocket> transport_socket_; | 142 scoped_ptr<StreamSocket> transport_socket_; |
| 141 | 143 |
| 142 // Options for the SSL socket. | 144 // Options for the SSL socket. |
| 143 SSLServerConfig ssl_config_; | 145 SSLServerConfig ssl_server_config_; |
| 144 | 146 |
| 145 // Certificate for the server. | 147 // Certificate for the server. |
| 146 scoped_refptr<X509Certificate> cert_; | 148 scoped_refptr<X509Certificate> cert_; |
| 147 | 149 |
| 148 // Private key used by the server. | 150 // Private key used by the server. |
| 149 scoped_ptr<crypto::RSAPrivateKey> key_; | 151 scoped_ptr<crypto::RSAPrivateKey> key_; |
| 150 | 152 |
| 153 // Certificate for the client. |
| 154 scoped_refptr<X509Certificate> client_cert_; |
| 155 |
| 151 State next_handshake_state_; | 156 State next_handshake_state_; |
| 152 bool completed_handshake_; | 157 bool completed_handshake_; |
| 153 | 158 |
| 154 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); | 159 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); |
| 155 }; | 160 }; |
| 156 | 161 |
| 157 } // namespace net | 162 } // namespace net |
| 158 | 163 |
| 159 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ | 164 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ |
| OLD | NEW |