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