| 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_config); |
| 35 ~SSLServerSocketOpenSSL() override; | 36 ~SSLServerSocketOpenSSL() override; |
| 36 | 37 |
| 37 // SSLServerSocket interface. | 38 // SSLServerSocket interface. |
| 38 int Handshake(const CompletionCallback& callback) override; | 39 int Handshake(const CompletionCallback& callback) override; |
| 40 void SetRequireClientCert(bool require_client_cert) override; |
| 41 void SetClientCertCAList(const CertificateList& client_cert_ca_list) override; |
| 42 void SetClientCertVerifier(CertVerifier* client_cert_verifier) override; |
| 39 | 43 |
| 40 // SSLSocket interface. | 44 // SSLSocket interface. |
| 41 int ExportKeyingMaterial(const base::StringPiece& label, | 45 int ExportKeyingMaterial(const base::StringPiece& label, |
| 42 bool has_context, | 46 bool has_context, |
| 43 const base::StringPiece& context, | 47 const base::StringPiece& context, |
| 44 unsigned char* out, | 48 unsigned char* out, |
| 45 unsigned int outlen) override; | 49 unsigned int outlen) override; |
| 46 int GetTLSUniqueChannelBinding(std::string* out) override; | 50 int GetTLSUniqueChannelBinding(std::string* out) override; |
| 47 | 51 |
| 48 // Socket interface (via StreamSocket). | 52 // Socket interface (via StreamSocket). |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 101 |
| 98 int DoHandshakeLoop(int last_io_result); | 102 int DoHandshakeLoop(int last_io_result); |
| 99 int DoReadLoop(int result); | 103 int DoReadLoop(int result); |
| 100 int DoWriteLoop(int result); | 104 int DoWriteLoop(int result); |
| 101 int DoHandshake(); | 105 int DoHandshake(); |
| 102 void DoHandshakeCallback(int result); | 106 void DoHandshakeCallback(int result); |
| 103 void DoReadCallback(int result); | 107 void DoReadCallback(int result); |
| 104 void DoWriteCallback(int result); | 108 void DoWriteCallback(int result); |
| 105 | 109 |
| 106 int Init(); | 110 int Init(); |
| 111 void ExtractClientCert(); |
| 112 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg); |
| 107 | 113 |
| 108 // Members used to send and receive buffer. | 114 // Members used to send and receive buffer. |
| 109 bool transport_send_busy_; | 115 bool transport_send_busy_; |
| 110 bool transport_recv_busy_; | 116 bool transport_recv_busy_; |
| 111 bool transport_recv_eof_; | 117 bool transport_recv_eof_; |
| 112 | 118 |
| 113 scoped_refptr<DrainableIOBuffer> send_buffer_; | 119 scoped_refptr<DrainableIOBuffer> send_buffer_; |
| 114 scoped_refptr<IOBuffer> recv_buffer_; | 120 scoped_refptr<IOBuffer> recv_buffer_; |
| 115 | 121 |
| 116 BoundNetLog net_log_; | 122 BoundNetLog net_log_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 140 | 146 |
| 141 // Options for the SSL socket. | 147 // Options for the SSL socket. |
| 142 SSLServerConfig ssl_config_; | 148 SSLServerConfig ssl_config_; |
| 143 | 149 |
| 144 // Certificate for the server. | 150 // Certificate for the server. |
| 145 scoped_refptr<X509Certificate> cert_; | 151 scoped_refptr<X509Certificate> cert_; |
| 146 | 152 |
| 147 // Private key used by the server. | 153 // Private key used by the server. |
| 148 scoped_ptr<crypto::RSAPrivateKey> key_; | 154 scoped_ptr<crypto::RSAPrivateKey> key_; |
| 149 | 155 |
| 156 // Certificate for the client. |
| 157 scoped_refptr<X509Certificate> client_cert_; |
| 158 |
| 150 State next_handshake_state_; | 159 State next_handshake_state_; |
| 151 bool completed_handshake_; | 160 bool completed_handshake_; |
| 152 | 161 |
| 162 // Information to be used in CertificateRequest message. |
| 163 CertificateList client_cert_ca_list_; |
| 164 |
| 165 // Used to provide callback for client certificate verification. |
| 166 CertVerifier* client_cert_verifier_; |
| 167 |
| 153 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); | 168 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); |
| 154 }; | 169 }; |
| 155 | 170 |
| 156 } // namespace net | 171 } // namespace net |
| 157 | 172 |
| 158 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ | 173 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ |
| OLD | NEW |