| 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 |
| 176 // Returns a unique key string for the SSL session cache for |
| 177 // this socket. |
| 178 std::string GetSessionCacheKey() const; |
| 179 |
| 187 bool transport_send_busy_; | 180 bool transport_send_busy_; |
| 188 bool transport_recv_busy_; | 181 bool transport_recv_busy_; |
| 189 | 182 |
| 190 // Buffers which are shared by BoringSSL and SSLClientSocketOpenSSL. | 183 // Buffers which are shared by BoringSSL and SSLClientSocketOpenSSL. |
| 191 // GrowableIOBuffer is used to keep ownership and setting offset. | 184 // GrowableIOBuffer is used to keep ownership and setting offset. |
| 192 scoped_refptr<GrowableIOBuffer> send_buffer_; | 185 scoped_refptr<GrowableIOBuffer> send_buffer_; |
| 193 scoped_refptr<GrowableIOBuffer> recv_buffer_; | 186 scoped_refptr<GrowableIOBuffer> recv_buffer_; |
| 194 | 187 |
| 195 CompletionCallback user_connect_callback_; | 188 CompletionCallback user_connect_callback_; |
| 196 CompletionCallback user_read_callback_; | 189 CompletionCallback user_read_callback_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 scoped_ptr<SingleRequestCertVerifier> verifier_; | 245 scoped_ptr<SingleRequestCertVerifier> verifier_; |
| 253 base::TimeTicks start_cert_verification_time_; | 246 base::TimeTicks start_cert_verification_time_; |
| 254 | 247 |
| 255 // Certificate Transparency: Verifier and result holder. | 248 // Certificate Transparency: Verifier and result holder. |
| 256 ct::CTVerifyResult ct_verify_result_; | 249 ct::CTVerifyResult ct_verify_result_; |
| 257 CTVerifier* cert_transparency_verifier_; | 250 CTVerifier* cert_transparency_verifier_; |
| 258 | 251 |
| 259 // The service for retrieving Channel ID keys. May be NULL. | 252 // The service for retrieving Channel ID keys. May be NULL. |
| 260 ChannelIDService* channel_id_service_; | 253 ChannelIDService* channel_id_service_; |
| 261 | 254 |
| 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 | 255 // OpenSSL stuff |
| 269 SSL* ssl_; | 256 SSL* ssl_; |
| 270 BIO* transport_bio_; | 257 BIO* transport_bio_; |
| 271 | 258 |
| 272 scoped_ptr<ClientSocketHandle> transport_; | 259 scoped_ptr<ClientSocketHandle> transport_; |
| 273 const HostPortPair host_and_port_; | 260 const HostPortPair host_and_port_; |
| 274 SSLConfig ssl_config_; | 261 SSLConfig ssl_config_; |
| 275 // ssl_session_cache_shard_ is an opaque string that partitions the SSL | 262 // 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 | 263 // session cache. i.e. sessions created with one value will not attempt to |
| 277 // resume on the socket with a different value. | 264 // resume on the socket with a different value. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 289 STATE_VERIFY_CERT_COMPLETE, | 276 STATE_VERIFY_CERT_COMPLETE, |
| 290 }; | 277 }; |
| 291 State next_handshake_state_; | 278 State next_handshake_state_; |
| 292 NextProtoStatus npn_status_; | 279 NextProtoStatus npn_status_; |
| 293 std::string npn_proto_; | 280 std::string npn_proto_; |
| 294 // Written by the |channel_id_service_|. | 281 // Written by the |channel_id_service_|. |
| 295 std::string channel_id_private_key_; | 282 std::string channel_id_private_key_; |
| 296 std::string channel_id_cert_; | 283 std::string channel_id_cert_; |
| 297 // True if channel ID extension was negotiated. | 284 // True if channel ID extension was negotiated. |
| 298 bool channel_id_xtn_negotiated_; | 285 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_; | |
| 304 // The request handle for |channel_id_service_|. | 286 // The request handle for |channel_id_service_|. |
| 305 ChannelIDService::RequestHandle channel_id_request_handle_; | 287 ChannelIDService::RequestHandle channel_id_request_handle_; |
| 306 | 288 |
| 307 TransportSecurityState* transport_security_state_; | 289 TransportSecurityState* transport_security_state_; |
| 308 | 290 |
| 309 CertPolicyEnforcer* const policy_enforcer_; | 291 CertPolicyEnforcer* const policy_enforcer_; |
| 310 | 292 |
| 311 // pinning_failure_log contains a message produced by | 293 // pinning_failure_log contains a message produced by |
| 312 // TransportSecurityState::CheckPublicKeyPins in the event of a | 294 // TransportSecurityState::CheckPublicKeyPins in the event of a |
| 313 // pinning failure. It is a (somewhat) human-readable string. | 295 // pinning failure. It is a (somewhat) human-readable string. |
| 314 std::string pinning_failure_log_; | 296 std::string pinning_failure_log_; |
| 315 | 297 |
| 316 BoundNetLog net_log_; | 298 BoundNetLog net_log_; |
| 317 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; | 299 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; |
| 318 }; | 300 }; |
| 319 | 301 |
| 320 } // namespace net | 302 } // namespace net |
| 321 | 303 |
| 322 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 304 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
| OLD | NEW |