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

Side by Side Diff: net/socket/ssl_server_socket_openssl.h

Issue 1474983003: Support for client certs in ssl_server_socket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits on utils Created 5 years 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
OLDNEW
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);
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;
39 40
40 // SSLSocket interface. 41 // SSLSocket interface.
41 int ExportKeyingMaterial(const base::StringPiece& label, 42 int ExportKeyingMaterial(const base::StringPiece& label,
42 bool has_context, 43 bool has_context,
43 const base::StringPiece& context, 44 const base::StringPiece& context,
44 unsigned char* out, 45 unsigned char* out,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 int DoHandshakeLoop(int last_io_result); 99 int DoHandshakeLoop(int last_io_result);
99 int DoReadLoop(int result); 100 int DoReadLoop(int result);
100 int DoWriteLoop(int result); 101 int DoWriteLoop(int result);
101 int DoHandshake(); 102 int DoHandshake();
102 void DoHandshakeCallback(int result); 103 void DoHandshakeCallback(int result);
103 void DoReadCallback(int result); 104 void DoReadCallback(int result);
104 void DoWriteCallback(int result); 105 void DoWriteCallback(int result);
105 106
106 int Init(); 107 int Init();
108 void ExtractClientCert();
109 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg);
107 110
108 // Members used to send and receive buffer. 111 // Members used to send and receive buffer.
109 bool transport_send_busy_; 112 bool transport_send_busy_;
110 bool transport_recv_busy_; 113 bool transport_recv_busy_;
111 bool transport_recv_eof_; 114 bool transport_recv_eof_;
112 115
113 scoped_refptr<DrainableIOBuffer> send_buffer_; 116 scoped_refptr<DrainableIOBuffer> send_buffer_;
114 scoped_refptr<IOBuffer> recv_buffer_; 117 scoped_refptr<IOBuffer> recv_buffer_;
115 118
116 BoundNetLog net_log_; 119 BoundNetLog net_log_;
(...skipping 15 matching lines...) Expand all
132 int transport_write_error_; 135 int transport_write_error_;
133 136
134 // OpenSSL stuff 137 // OpenSSL stuff
135 SSL* ssl_; 138 SSL* ssl_;
136 BIO* transport_bio_; 139 BIO* transport_bio_;
137 140
138 // StreamSocket for sending and receiving data. 141 // StreamSocket for sending and receiving data.
139 scoped_ptr<StreamSocket> transport_socket_; 142 scoped_ptr<StreamSocket> transport_socket_;
140 143
141 // Options for the SSL socket. 144 // Options for the SSL socket.
142 SSLServerConfig ssl_config_; 145 SSLServerConfig ssl_server_config_;
143 146
144 // Certificate for the server. 147 // Certificate for the server.
145 scoped_refptr<X509Certificate> cert_; 148 scoped_refptr<X509Certificate> cert_;
146 149
147 // Private key used by the server. 150 // Private key used by the server.
148 scoped_ptr<crypto::RSAPrivateKey> key_; 151 scoped_ptr<crypto::RSAPrivateKey> key_;
149 152
153 // Certificate for the client.
154 scoped_refptr<X509Certificate> client_cert_;
155
150 State next_handshake_state_; 156 State next_handshake_state_;
151 bool completed_handshake_; 157 bool completed_handshake_;
152 158
153 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); 159 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL);
154 }; 160 };
155 161
156 } // namespace net 162 } // namespace net
157 163
158 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ 164 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698