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

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

Issue 994743003: Support for client certs in ssl_server_socket. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/base/completion_callback.h" 9 #include "net/base/completion_callback.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "net/base/net_log.h" 11 #include "net/base/net_log.h"
12 #include "net/socket/ssl_server_socket.h" 12 #include "net/socket/ssl_server_socket.h"
13 #include "net/ssl/ssl_config_service.h" 13 #include "net/ssl/ssl_config_service.h"
14 14
15 // Avoid including misc OpenSSL headers, i.e.: 15 // Avoid including misc OpenSSL headers, i.e.:
16 // <openssl/bio.h> 16 // <openssl/bio.h>
17 typedef struct bio_st BIO; 17 typedef struct bio_st BIO;
18 // <openssl/ssl.h> 18 // <openssl/ssl.h>
19 typedef struct ssl_st SSL; 19 typedef struct ssl_st SSL;
20 typedef struct x509_store_ctx_st X509_STORE_CTX;
20 21
21 namespace net { 22 namespace net {
22 23
23 class SSLInfo; 24 class SSLInfo;
24 25
25 class SSLServerSocketOpenSSL : public SSLServerSocket { 26 class SSLServerSocketOpenSSL : public SSLServerSocket {
26 public: 27 public:
27 // See comments on CreateSSLServerSocket for details of how these 28 // See comments on CreateSSLServerSocket for details of how these
28 // parameters are used. 29 // parameters are used.
29 SSLServerSocketOpenSSL(scoped_ptr<StreamSocket> socket, 30 SSLServerSocketOpenSSL(scoped_ptr<StreamSocket> socket,
30 scoped_refptr<X509Certificate> certificate, 31 scoped_refptr<X509Certificate> certificate,
31 crypto::RSAPrivateKey* key, 32 crypto::RSAPrivateKey* key,
32 const SSLConfig& ssl_config); 33 const SSLConfig& ssl_config);
33 ~SSLServerSocketOpenSSL() override; 34 ~SSLServerSocketOpenSSL() override;
34 35
35 // SSLServerSocket interface. 36 // SSLServerSocket interface.
36 int Handshake(const CompletionCallback& callback) override; 37 int Handshake(const CompletionCallback& callback) override;
38 void SetAllowClientCert(bool allow_client_cert) override;
39 void SetClientCertCAList(const CertificateList& client_cert_ca_list) override;
40 void SetClientCertVerifier(CertVerifier* client_cert_verifier) override;
37 41
38 // SSLSocket interface. 42 // SSLSocket interface.
39 int ExportKeyingMaterial(const base::StringPiece& label, 43 int ExportKeyingMaterial(const base::StringPiece& label,
40 bool has_context, 44 bool has_context,
41 const base::StringPiece& context, 45 const base::StringPiece& context,
42 unsigned char* out, 46 unsigned char* out,
43 unsigned int outlen) override; 47 unsigned int outlen) override;
44 int GetTLSUniqueChannelBinding(std::string* out) override; 48 int GetTLSUniqueChannelBinding(std::string* out) override;
45 49
46 // Socket interface (via StreamSocket). 50 // Socket interface (via StreamSocket).
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 95
92 int DoHandshakeLoop(int last_io_result); 96 int DoHandshakeLoop(int last_io_result);
93 int DoReadLoop(int result); 97 int DoReadLoop(int result);
94 int DoWriteLoop(int result); 98 int DoWriteLoop(int result);
95 int DoHandshake(); 99 int DoHandshake();
96 void DoHandshakeCallback(int result); 100 void DoHandshakeCallback(int result);
97 void DoReadCallback(int result); 101 void DoReadCallback(int result);
98 void DoWriteCallback(int result); 102 void DoWriteCallback(int result);
99 103
100 int Init(); 104 int Init();
105 void ExtractClientCert();
106 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg);
101 107
102 // Members used to send and receive buffer. 108 // Members used to send and receive buffer.
103 bool transport_send_busy_; 109 bool transport_send_busy_;
104 bool transport_recv_busy_; 110 bool transport_recv_busy_;
105 bool transport_recv_eof_; 111 bool transport_recv_eof_;
106 112
107 scoped_refptr<DrainableIOBuffer> send_buffer_; 113 scoped_refptr<DrainableIOBuffer> send_buffer_;
108 scoped_refptr<IOBuffer> recv_buffer_; 114 scoped_refptr<IOBuffer> recv_buffer_;
109 115
110 BoundNetLog net_log_; 116 BoundNetLog net_log_;
(...skipping 23 matching lines...) Expand all
134 140
135 // Options for the SSL socket. 141 // Options for the SSL socket.
136 SSLConfig ssl_config_; 142 SSLConfig ssl_config_;
137 143
138 // Certificate for the server. 144 // Certificate for the server.
139 scoped_refptr<X509Certificate> cert_; 145 scoped_refptr<X509Certificate> cert_;
140 146
141 // Private key used by the server. 147 // Private key used by the server.
142 scoped_ptr<crypto::RSAPrivateKey> key_; 148 scoped_ptr<crypto::RSAPrivateKey> key_;
143 149
150 // Certificate for the client.
151 scoped_refptr<X509Certificate> client_cert_;
152
144 State next_handshake_state_; 153 State next_handshake_state_;
145 bool completed_handshake_; 154 bool completed_handshake_;
146 155
156 // Information to be used in CertificateRequest message.
157 CertificateList client_cert_ca_list_;
158
159 // Used to provide callback for client certificate verification.
160 CertVerifier* client_cert_verifier_;
161
147 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL); 162 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL);
148 }; 163 };
149 164
150 } // namespace net 165 } // namespace net
151 166
152 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ 167 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698