OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CLIENT_SOCKET_OPENSSL_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
6 #define NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 const SSLConfig& ssl_config, | 53 const SSLConfig& ssl_config, |
54 const SSLClientSocketContext& context); | 54 const SSLClientSocketContext& context); |
55 ~SSLClientSocketOpenSSL() override; | 55 ~SSLClientSocketOpenSSL() override; |
56 | 56 |
57 const HostPortPair& host_and_port() const { return host_and_port_; } | 57 const HostPortPair& host_and_port() const { return host_and_port_; } |
58 const std::string& ssl_session_cache_shard() const { | 58 const std::string& ssl_session_cache_shard() const { |
59 return ssl_session_cache_shard_; | 59 return ssl_session_cache_shard_; |
60 } | 60 } |
61 | 61 |
62 // SSLClientSocket implementation. | 62 // SSLClientSocket implementation. |
63 std::string GetSessionCacheKey() const override; | |
64 bool InSessionCache() const override; | |
65 void SetHandshakeCompletionCallback(const base::Closure& callback) override; | |
66 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; | 63 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
67 NextProtoStatus GetNextProto(std::string* proto) override; | 64 NextProtoStatus GetNextProto(std::string* proto) override; |
68 ChannelIDService* GetChannelIDService() const override; | 65 ChannelIDService* GetChannelIDService() const override; |
69 | 66 |
70 // SSLSocket implementation. | 67 // SSLSocket implementation. |
71 int ExportKeyingMaterial(const base::StringPiece& label, | 68 int ExportKeyingMaterial(const base::StringPiece& label, |
72 bool has_context, | 69 bool has_context, |
73 const base::StringPiece& context, | 70 const base::StringPiece& context, |
74 unsigned char* out, | 71 unsigned char* out, |
75 unsigned int outlen) override; | 72 unsigned int outlen) override; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 private: | 104 private: |
108 class PeerCertificateChain; | 105 class PeerCertificateChain; |
109 class SSLContext; | 106 class SSLContext; |
110 friend class SSLClientSocket; | 107 friend class SSLClientSocket; |
111 friend class SSLContext; | 108 friend class SSLContext; |
112 | 109 |
113 int Init(); | 110 int Init(); |
114 void DoReadCallback(int result); | 111 void DoReadCallback(int result); |
115 void DoWriteCallback(int result); | 112 void DoWriteCallback(int result); |
116 | 113 |
117 void OnHandshakeCompletion(); | |
118 | |
119 bool DoTransportIO(); | 114 bool DoTransportIO(); |
120 int DoHandshake(); | 115 int DoHandshake(); |
121 int DoChannelIDLookup(); | 116 int DoChannelIDLookup(); |
122 int DoChannelIDLookupComplete(int result); | 117 int DoChannelIDLookupComplete(int result); |
123 int DoVerifyCert(int result); | 118 int DoVerifyCert(int result); |
124 int DoVerifyCertComplete(int result); | 119 int DoVerifyCertComplete(int result); |
125 void DoConnectCallback(int result); | 120 void DoConnectCallback(int result); |
126 void UpdateServerCert(); | 121 void UpdateServerCert(); |
127 void VerifyCT(); | 122 void VerifyCT(); |
128 | 123 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 const char *argp, int argi, long argl, | 159 const char *argp, int argi, long argl, |
165 long retvalue); | 160 long retvalue); |
166 | 161 |
167 // Callback from the SSL layer when an operation is performed on | 162 // Callback from the SSL layer when an operation is performed on |
168 // |transport_bio_|'s peer. | 163 // |transport_bio_|'s peer. |
169 static long BIOCallback(BIO *bio, | 164 static long BIOCallback(BIO *bio, |
170 int cmd, | 165 int cmd, |
171 const char *argp, int argi, long argl, | 166 const char *argp, int argi, long argl, |
172 long retvalue); | 167 long retvalue); |
173 | 168 |
174 // Callback that is used to obtain information about the state of the SSL | |
175 // handshake. | |
176 static void InfoCallback(const SSL* ssl, int type, int val); | |
177 | |
178 void CheckIfHandshakeFinished(); | |
179 | |
180 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|. | 169 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|. |
181 // SCTs are held in three separate vectors in ct_verify_result, each | 170 // SCTs are held in three separate vectors in ct_verify_result, each |
182 // vetor representing a particular verification state, this method associates | 171 // vetor representing a particular verification state, this method associates |
183 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to | 172 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to |
184 // the |ssl_info|.signed_certificate_timestamps list. | 173 // the |ssl_info|.signed_certificate_timestamps list. |
185 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const; | 174 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const; |
186 | 175 |
187 bool transport_send_busy_; | 176 bool transport_send_busy_; |
188 bool transport_recv_busy_; | 177 bool transport_recv_busy_; |
189 | 178 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 | 210 |
222 // Used by TransportReadComplete() to signify an error reading from the | 211 // Used by TransportReadComplete() to signify an error reading from the |
223 // transport socket. A value of OK indicates the socket is still | 212 // transport socket. A value of OK indicates the socket is still |
224 // readable. EOFs are mapped to ERR_CONNECTION_CLOSED. | 213 // readable. EOFs are mapped to ERR_CONNECTION_CLOSED. |
225 int transport_read_error_; | 214 int transport_read_error_; |
226 | 215 |
227 // Used by TransportWriteComplete() and TransportReadComplete() to signify an | 216 // Used by TransportWriteComplete() and TransportReadComplete() to signify an |
228 // error writing to the transport socket. A value of OK indicates no error. | 217 // error writing to the transport socket. A value of OK indicates no error. |
229 int transport_write_error_; | 218 int transport_write_error_; |
230 | 219 |
231 // Set when Connect finishes. | 220 // Set when handshake finishes. |
232 scoped_ptr<PeerCertificateChain> server_cert_chain_; | 221 scoped_ptr<PeerCertificateChain> server_cert_chain_; |
233 scoped_refptr<X509Certificate> server_cert_; | 222 scoped_refptr<X509Certificate> server_cert_; |
234 CertVerifyResult server_cert_verify_result_; | 223 CertVerifyResult server_cert_verify_result_; |
235 bool completed_connect_; | 224 bool completed_handshake_; |
davidben
2015/03/09 18:02:36
I think the LHS naming is actually more accurate i
| |
236 | 225 |
237 // Set when Read() or Write() successfully reads or writes data to or from the | 226 // Set when Read() or Write() successfully reads or writes data to or from the |
238 // network. | 227 // network. |
239 bool was_ever_used_; | 228 bool was_ever_used_; |
240 | 229 |
241 // Stores client authentication information between ClientAuthHandler and | 230 // Stores client authentication information between ClientAuthHandler and |
242 // GetSSLCertRequestInfo calls. | 231 // GetSSLCertRequestInfo calls. |
243 bool client_auth_cert_needed_; | 232 bool client_auth_cert_needed_; |
244 // List of DER-encoded X.509 DistinguishedName of certificate authorities | 233 // List of DER-encoded X.509 DistinguishedName of certificate authorities |
245 // allowed by the server. | 234 // allowed by the server. |
246 std::vector<std::string> cert_authorities_; | 235 std::vector<std::string> cert_authorities_; |
247 // List of SSLClientCertType values for client certificates allowed by the | 236 // List of SSLClientCertType values for client certificates allowed by the |
248 // server. | 237 // server. |
249 std::vector<SSLClientCertType> cert_key_types_; | 238 std::vector<SSLClientCertType> cert_key_types_; |
250 | 239 |
251 CertVerifier* const cert_verifier_; | 240 CertVerifier* const cert_verifier_; |
252 scoped_ptr<SingleRequestCertVerifier> verifier_; | 241 scoped_ptr<SingleRequestCertVerifier> verifier_; |
253 base::TimeTicks start_cert_verification_time_; | 242 base::TimeTicks start_cert_verification_time_; |
254 | 243 |
255 // Certificate Transparency: Verifier and result holder. | 244 // Certificate Transparency: Verifier and result holder. |
256 ct::CTVerifyResult ct_verify_result_; | 245 ct::CTVerifyResult ct_verify_result_; |
257 CTVerifier* cert_transparency_verifier_; | 246 CTVerifier* cert_transparency_verifier_; |
258 | 247 |
259 // The service for retrieving Channel ID keys. May be NULL. | 248 // The service for retrieving Channel ID keys. May be NULL. |
260 ChannelIDService* channel_id_service_; | 249 ChannelIDService* channel_id_service_; |
261 | 250 |
262 // Callback that is invoked when the connection finishes. | |
263 // | |
264 // Note: this callback will be run in Disconnect(). It will not alter | |
265 // any member variables of the SSLClientSocketOpenSSL. | |
266 base::Closure handshake_completion_callback_; | |
267 | |
268 // OpenSSL stuff | 251 // OpenSSL stuff |
269 SSL* ssl_; | 252 SSL* ssl_; |
270 BIO* transport_bio_; | 253 BIO* transport_bio_; |
271 | 254 |
272 scoped_ptr<ClientSocketHandle> transport_; | 255 scoped_ptr<ClientSocketHandle> transport_; |
273 const HostPortPair host_and_port_; | 256 const HostPortPair host_and_port_; |
274 SSLConfig ssl_config_; | 257 SSLConfig ssl_config_; |
275 // ssl_session_cache_shard_ is an opaque string that partitions the SSL | 258 // ssl_session_cache_shard_ is an opaque string that partitions the SSL |
276 // session cache. i.e. sessions created with one value will not attempt to | 259 // session cache. i.e. sessions created with one value will not attempt to |
277 // resume on the socket with a different value. | 260 // resume on the socket with a different value. |
(...skipping 11 matching lines...) Expand all Loading... | |
289 STATE_VERIFY_CERT_COMPLETE, | 272 STATE_VERIFY_CERT_COMPLETE, |
290 }; | 273 }; |
291 State next_handshake_state_; | 274 State next_handshake_state_; |
292 NextProtoStatus npn_status_; | 275 NextProtoStatus npn_status_; |
293 std::string npn_proto_; | 276 std::string npn_proto_; |
294 // Written by the |channel_id_service_|. | 277 // Written by the |channel_id_service_|. |
295 std::string channel_id_private_key_; | 278 std::string channel_id_private_key_; |
296 std::string channel_id_cert_; | 279 std::string channel_id_cert_; |
297 // True if channel ID extension was negotiated. | 280 // True if channel ID extension was negotiated. |
298 bool channel_id_xtn_negotiated_; | 281 bool channel_id_xtn_negotiated_; |
299 // True if InfoCallback has been run with result = SSL_CB_HANDSHAKE_DONE. | |
300 bool handshake_succeeded_; | |
301 // True if MarkSSLSessionAsGood has been called for this socket's | |
302 // SSL session. | |
303 bool marked_session_as_good_; | |
davidben
2015/03/09 18:02:36
Fine to remove this now, but my session cache CL w
| |
304 // The request handle for |channel_id_service_|. | 282 // The request handle for |channel_id_service_|. |
305 ChannelIDService::RequestHandle channel_id_request_handle_; | 283 ChannelIDService::RequestHandle channel_id_request_handle_; |
306 | 284 |
307 TransportSecurityState* transport_security_state_; | 285 TransportSecurityState* transport_security_state_; |
308 | 286 |
309 CertPolicyEnforcer* const policy_enforcer_; | 287 CertPolicyEnforcer* const policy_enforcer_; |
310 | 288 |
311 // pinning_failure_log contains a message produced by | 289 // pinning_failure_log contains a message produced by |
312 // TransportSecurityState::CheckPublicKeyPins in the event of a | 290 // TransportSecurityState::CheckPublicKeyPins in the event of a |
313 // pinning failure. It is a (somewhat) human-readable string. | 291 // pinning failure. It is a (somewhat) human-readable string. |
314 std::string pinning_failure_log_; | 292 std::string pinning_failure_log_; |
315 | 293 |
316 BoundNetLog net_log_; | 294 BoundNetLog net_log_; |
317 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; | 295 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; |
318 }; | 296 }; |
319 | 297 |
320 } // namespace net | 298 } // namespace net |
321 | 299 |
322 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 300 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
OLD | NEW |