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

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

Issue 1518613002: Support for server session cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_certs
Patch Set: Added a missing period. Created 4 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 <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/scoped_openssl_types.h"
16 #include "net/ssl/ssl_server_config.h" 17 #include "net/ssl/ssl_server_config.h"
17 18
18 // Avoid including misc OpenSSL headers, i.e.: 19 // Avoid including misc OpenSSL headers, i.e.:
19 // <openssl/bio.h> 20 // <openssl/bio.h>
20 typedef struct bio_st BIO; 21 typedef struct bio_st BIO;
21 // <openssl/ssl.h> 22 // <openssl/ssl.h>
22 typedef struct ssl_st SSL; 23 typedef struct ssl_st SSL;
23 typedef struct x509_store_ctx_st X509_STORE_CTX; 24 typedef struct x509_store_ctx_st X509_STORE_CTX;
24 25
25 namespace net { 26 namespace net {
26 27
27 class SSLInfo; 28 class SSLInfo;
28 29
29 class SSLServerSocketOpenSSL : public SSLServerSocket { 30 class SSLServerContextOpenSSL : public SSLServerContext {
30 public: 31 public:
31 // See comments on CreateSSLServerSocket for details of how these 32 SSLServerContextOpenSSL(X509Certificate* certificate,
32 // parameters are used. 33 const crypto::RSAPrivateKey& key,
33 SSLServerSocketOpenSSL(scoped_ptr<StreamSocket> socket, 34 const SSLServerConfig& ssl_server_config);
34 scoped_refptr<X509Certificate> certificate, 35 ~SSLServerContextOpenSSL() override;
35 const crypto::RSAPrivateKey& key,
36 const SSLServerConfig& ssl_server_config);
37 ~SSLServerSocketOpenSSL() override;
38 36
39 // SSLServerSocket interface. 37 scoped_ptr<SSLServerSocket> CreateSSLServerSocket(
40 int Handshake(const CompletionCallback& callback) override; 38 scoped_ptr<StreamSocket> socket) override;
41
42 // SSLSocket interface.
43 int ExportKeyingMaterial(const base::StringPiece& label,
44 bool has_context,
45 const base::StringPiece& context,
46 unsigned char* out,
47 unsigned int outlen) override;
48 int GetTLSUniqueChannelBinding(std::string* out) override;
49
50 // Socket interface (via StreamSocket).
51 int Read(IOBuffer* buf,
52 int buf_len,
53 const CompletionCallback& callback) override;
54 int Write(IOBuffer* buf,
55 int buf_len,
56 const CompletionCallback& callback) override;
57 int SetReceiveBufferSize(int32_t size) override;
58 int SetSendBufferSize(int32_t size) override;
59
60 // StreamSocket implementation.
61 int Connect(const CompletionCallback& callback) override;
62 void Disconnect() override;
63 bool IsConnected() const override;
64 bool IsConnectedAndIdle() const override;
65 int GetPeerAddress(IPEndPoint* address) const override;
66 int GetLocalAddress(IPEndPoint* address) const override;
67 const BoundNetLog& NetLog() const override;
68 void SetSubresourceSpeculation() override;
69 void SetOmniboxSpeculation() override;
70 bool WasEverUsed() const override;
71 bool UsingTCPFastOpen() const override;
72 bool WasNpnNegotiated() const override;
73 NextProto GetNegotiatedProtocol() const override;
74 bool GetSSLInfo(SSLInfo* ssl_info) override;
75 void GetConnectionAttempts(ConnectionAttempts* out) const override;
76 void ClearConnectionAttempts() override {}
77 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
78 int64_t GetTotalReceivedBytes() const override;
79 39
80 private: 40 private:
81 enum State { 41 ScopedSSL_CTX ssl_ctx_;
82 STATE_NONE,
83 STATE_HANDSHAKE,
84 };
85
86 void OnSendComplete(int result);
87 void OnRecvComplete(int result);
88 void OnHandshakeIOComplete(int result);
89
90 int BufferSend();
91 void BufferSendComplete(int result);
92 void TransportWriteComplete(int result);
93 int BufferRecv();
94 void BufferRecvComplete(int result);
95 int TransportReadComplete(int result);
96 bool DoTransportIO();
97 int DoPayloadRead();
98 int DoPayloadWrite();
99
100 int DoHandshakeLoop(int last_io_result);
101 int DoReadLoop(int result);
102 int DoWriteLoop(int result);
103 int DoHandshake();
104 void DoHandshakeCallback(int result);
105 void DoReadCallback(int result);
106 void DoWriteCallback(int result);
107
108 int Init();
109 static int CertVerifyCallback(X509_STORE_CTX* store_ctx, void* arg);
110
111 // Members used to send and receive buffer.
112 bool transport_send_busy_;
113 bool transport_recv_busy_;
114 bool transport_recv_eof_;
115
116 scoped_refptr<DrainableIOBuffer> send_buffer_;
117 scoped_refptr<IOBuffer> recv_buffer_;
118
119 BoundNetLog net_log_;
120
121 CompletionCallback user_handshake_callback_;
122 CompletionCallback user_read_callback_;
123 CompletionCallback user_write_callback_;
124
125 // Used by Read function.
126 scoped_refptr<IOBuffer> user_read_buf_;
127 int user_read_buf_len_;
128
129 // Used by Write function.
130 scoped_refptr<IOBuffer> user_write_buf_;
131 int user_write_buf_len_;
132
133 // Used by TransportWriteComplete() and TransportReadComplete() to signify an
134 // error writing to the transport socket. A value of OK indicates no error.
135 int transport_write_error_;
136
137 // OpenSSL stuff
138 SSL* ssl_;
139 BIO* transport_bio_;
140
141 // StreamSocket for sending and receiving data.
142 scoped_ptr<StreamSocket> transport_socket_;
143 42
144 // Options for the SSL socket. 43 // Options for the SSL socket.
145 SSLServerConfig ssl_server_config_; 44 SSLServerConfig ssl_server_config_;
146 45
147 // Certificate for the server. 46 // Certificate for the server.
148 scoped_refptr<X509Certificate> cert_; 47 scoped_refptr<X509Certificate> cert_;
149 48
150 // Private key used by the server. 49 // Private key used by the server.
151 scoped_ptr<crypto::RSAPrivateKey> key_; 50 scoped_ptr<crypto::RSAPrivateKey> key_;
152
153 // Certificate for the client.
154 scoped_refptr<X509Certificate> client_cert_;
155
156 State next_handshake_state_;
157 bool completed_handshake_;
158
159 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketOpenSSL);
160 }; 51 };
161 52
162 } // namespace net 53 } // namespace net
163 54
164 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_ 55 #endif // NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698