[email protected] | 61f3ddf | 2012-02-08 02:45:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
svaldez | e83af29 | 2016-04-26 14:33:37 | [diff] [blame] | 5 | #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_IMPL_H_ |
| 6 | #define NET_SOCKET_SSL_CLIENT_SOCKET_IMPL_H_ |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 7 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 8 | #include <stddef.h> |
tbansal | f82cc8e | 2015-10-14 20:05:49 | [diff] [blame] | 9 | #include <stdint.h> |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 10 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 11 | #include <memory> |
[email protected] | ea4a1c6a | 2010-12-09 13:33:28 | [diff] [blame] | 12 | #include <string> |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 13 | #include <vector> |
[email protected] | ea4a1c6a | 2010-12-09 13:33:28 | [diff] [blame] | 14 | |
nharper | b7441ef | 2016-01-25 23:54:14 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
| 16 | #include "base/containers/mru_cache.h" |
David Benjamin | e34d7424 | 2017-06-29 20:35:16 | [diff] [blame] | 17 | #include "base/macros.h" |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 18 | #include "base/memory/ref_counted.h" |
[email protected] | be90ba3 | 2013-05-13 20:05:25 | [diff] [blame] | 19 | #include "base/memory/weak_ptr.h" |
Mario Sanchez Prada | 3f9c238 | 2019-04-03 22:31:14 | [diff] [blame] | 20 | #include "net/base/completion_once_callback.h" |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 21 | #include "net/base/host_port_pair.h" |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 22 | #include "net/base/io_buffer.h" |
eroman | 7f9236a | 2015-05-11 21:23:43 | [diff] [blame] | 23 | #include "net/cert/cert_verifier.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 24 | #include "net/cert/cert_verify_result.h" |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 25 | #include "net/cert/ct_verify_result.h" |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 26 | #include "net/log/net_log_with_source.h" |
bnc | 3472afd | 2016-11-17 15:27:21 | [diff] [blame] | 27 | #include "net/socket/next_proto.h" |
davidben | 3418e81f | 2016-10-19 00:09:45 | [diff] [blame] | 28 | #include "net/socket/socket_bio_adapter.h" |
[email protected] | 536fd0b | 2013-03-14 17:41:57 | [diff] [blame] | 29 | #include "net/socket/ssl_client_socket.h" |
Matt Menke | fd95692 | 2019-02-04 23:44:03 | [diff] [blame] | 30 | #include "net/socket/stream_socket.h" |
davidben | b8c2321 | 2014-10-28 00:12:16 | [diff] [blame] | 31 | #include "net/ssl/openssl_ssl_util.h" |
[email protected] | c078770 | 2014-05-20 21:51:44 | [diff] [blame] | 32 | #include "net/ssl/ssl_client_cert_type.h" |
Ryan Sleevi | b369d71 | 2018-08-20 16:43:22 | [diff] [blame] | 33 | #include "net/ssl/ssl_config.h" |
[email protected] | a2b2cfc | 2017-12-06 09:06:08 | [diff] [blame] | 34 | #include "net/traffic_annotation/network_traffic_annotation.h" |
tfarina | e8cb8aa | 2016-10-21 02:44:01 | [diff] [blame] | 35 | #include "third_party/boringssl/src/include/openssl/base.h" |
| 36 | #include "third_party/boringssl/src/include/openssl/ssl.h" |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 37 | |
davidben | fe132d9 | 2016-09-27 18:07:21 | [diff] [blame] | 38 | namespace crypto { |
| 39 | class OpenSSLErrStackTracer; |
| 40 | } |
| 41 | |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 42 | namespace net { |
| 43 | |
[email protected] | 170e76c | 2010-10-04 15:04:20 | [diff] [blame] | 44 | class CertVerifier; |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 45 | class CTVerifier; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 46 | class SSLCertRequestInfo; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 47 | class SSLInfo; |
David Benjamin | bd37c17 | 2018-07-11 17:24:57 | [diff] [blame] | 48 | class SSLKeyLogger; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 49 | |
davidben | 3418e81f | 2016-10-19 00:09:45 | [diff] [blame] | 50 | class SSLClientSocketImpl : public SSLClientSocket, |
| 51 | public SocketBIOAdapter::Delegate { |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 52 | public: |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 53 | // Takes ownership of |stream_socket|, which may already be connected. |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 54 | // The given hostname will be compared with the name(s) in the server's |
Matt Menke | fd95692 | 2019-02-04 23:44:03 | [diff] [blame] | 55 | // certificate during the SSL handshake. |ssl_config| specifies the SSL |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 56 | // settings. |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 57 | SSLClientSocketImpl(std::unique_ptr<StreamSocket> stream_socket, |
Matt Menke | fd95692 | 2019-02-04 23:44:03 | [diff] [blame] | 58 | const HostPortPair& host_and_port, |
| 59 | const SSLConfig& ssl_config, |
| 60 | const SSLClientSocketContext& context); |
svaldez | e83af29 | 2016-04-26 14:33:37 | [diff] [blame] | 61 | ~SSLClientSocketImpl() override; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 62 | |
[email protected] | fbef1393 | 2010-11-23 12:38:53 | [diff] [blame] | 63 | const HostPortPair& host_and_port() const { return host_and_port_; } |
[email protected] | fbef1393 | 2010-11-23 12:38:53 | [diff] [blame] | 64 | |
David Benjamin | bd37c17 | 2018-07-11 17:24:57 | [diff] [blame] | 65 | // Log SSL key material to |logger|. Must be called before any |
| 66 | // SSLClientSockets are created. |
| 67 | static void SetSSLKeyLogger(std::unique_ptr<SSLKeyLogger> logger); |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 68 | |
[email protected] | 81ec7c1 | 2012-07-31 18:32:19 | [diff] [blame] | 69 | // SSLSocket implementation. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 70 | int ExportKeyingMaterial(const base::StringPiece& label, |
| 71 | bool has_context, |
| 72 | const base::StringPiece& context, |
| 73 | unsigned char* out, |
| 74 | unsigned int outlen) override; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 75 | |
[email protected] | dbf036f | 2011-12-06 23:33:24 | [diff] [blame] | 76 | // StreamSocket implementation. |
Brad Lassey | 3a81417 | 2018-04-26 03:30:21 | [diff] [blame] | 77 | int Connect(CompletionOnceCallback callback) override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 78 | void Disconnect() override; |
Steven Valdez | 6af02df | 2018-07-15 21:52:33 | [diff] [blame] | 79 | int ConfirmHandshake(CompletionOnceCallback callback) override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 80 | bool IsConnected() const override; |
| 81 | bool IsConnectedAndIdle() const override; |
| 82 | int GetPeerAddress(IPEndPoint* address) const override; |
| 83 | int GetLocalAddress(IPEndPoint* address) const override; |
tfarina | 42834111 | 2016-09-22 13:38:20 | [diff] [blame] | 84 | const NetLogWithSource& NetLog() const override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 85 | bool WasEverUsed() const override; |
tfarina | 2846404c | 2016-12-25 14:31:37 | [diff] [blame] | 86 | bool WasAlpnNegotiated() const override; |
bnc | 3cf2a59 | 2016-08-11 14:48:36 | [diff] [blame] | 87 | NextProto GetNegotiatedProtocol() const override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 88 | bool GetSSLInfo(SSLInfo* ssl_info) override; |
ttuttle | 23fdb7b | 2015-05-15 01:28:03 | [diff] [blame] | 89 | void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 90 | void ClearConnectionAttempts() override {} |
| 91 | void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
tbansal | f82cc8e | 2015-10-14 20:05:49 | [diff] [blame] | 92 | int64_t GetTotalReceivedBytes() const override; |
xunjieli | 998d247 | 2017-01-12 01:12:28 | [diff] [blame] | 93 | void DumpMemoryStats(SocketMemoryStats* stats) const override; |
Bence Béky | dae8af5f | 2018-04-13 08:53:17 | [diff] [blame] | 94 | void GetSSLCertRequestInfo( |
| 95 | SSLCertRequestInfo* cert_request_info) const override; |
Bence Béky | dae8af5f | 2018-04-13 08:53:17 | [diff] [blame] | 96 | |
Paul Jensen | 0f49dec | 2017-12-12 23:39:58 | [diff] [blame] | 97 | void ApplySocketTag(const SocketTag& tag) override; |
xunjieli | 9f8c5fb5 | 2016-12-07 22:59:33 | [diff] [blame] | 98 | |
[email protected] | dbf036f | 2011-12-06 23:33:24 | [diff] [blame] | 99 | // Socket implementation. |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 100 | int Read(IOBuffer* buf, |
| 101 | int buf_len, |
Brad Lassey | 3a81417 | 2018-04-26 03:30:21 | [diff] [blame] | 102 | CompletionOnceCallback callback) override; |
xunjieli | 321a96f3 | 2017-03-07 19:42:17 | [diff] [blame] | 103 | int ReadIfReady(IOBuffer* buf, |
| 104 | int buf_len, |
Brad Lassey | 3a81417 | 2018-04-26 03:30:21 | [diff] [blame] | 105 | CompletionOnceCallback callback) override; |
Helen Li | 5f3d96a | 2018-08-10 20:37:24 | [diff] [blame] | 106 | int CancelReadIfReady() override; |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 107 | int Write(IOBuffer* buf, |
| 108 | int buf_len, |
Brad Lassey | 3a81417 | 2018-04-26 03:30:21 | [diff] [blame] | 109 | CompletionOnceCallback callback, |
[email protected] | 578968d4 | 2017-12-13 15:39:32 | [diff] [blame] | 110 | const NetworkTrafficAnnotationTag& traffic_annotation) override; |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 111 | int SetReceiveBufferSize(int32_t size) override; |
| 112 | int SetSendBufferSize(int32_t size) override; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 113 | |
davidben | 3418e81f | 2016-10-19 00:09:45 | [diff] [blame] | 114 | // SocketBIOAdapter implementation: |
| 115 | void OnReadReady() override; |
| 116 | void OnWriteReady() override; |
| 117 | |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 118 | private: |
[email protected] | 7f38da8a | 2014-03-17 16:44:26 | [diff] [blame] | 119 | class PeerCertificateChain; |
[email protected] | 821e3bb | 2013-11-08 01:06:01 | [diff] [blame] | 120 | class SSLContext; |
| 121 | friend class SSLClientSocket; |
| 122 | friend class SSLContext; |
| 123 | |
[email protected] | c8a80e9 | 2014-05-17 16:02:08 | [diff] [blame] | 124 | int Init(); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 125 | void DoReadCallback(int result); |
| 126 | void DoWriteCallback(int result); |
| 127 | |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 128 | int DoHandshake(); |
davidben | c4212c0 | 2015-05-12 22:30:18 | [diff] [blame] | 129 | int DoHandshakeComplete(int result); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 130 | void DoConnectCallback(int result); |
| 131 | |
Jesse Selover | 94c9a94 | 2019-01-16 01:18:04 | [diff] [blame] | 132 | void OnVerifyComplete(int result); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 133 | void OnHandshakeIOComplete(int result); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 134 | |
| 135 | int DoHandshakeLoop(int last_io_result); |
xunjieli | 321a96f3 | 2017-03-07 19:42:17 | [diff] [blame] | 136 | int DoPayloadRead(IOBuffer* buf, int buf_len); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 137 | int DoPayloadWrite(); |
| 138 | |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 139 | // Called when an asynchronous event completes which may have blocked the |
davidben | 3418e81f | 2016-10-19 00:09:45 | [diff] [blame] | 140 | // pending Connect, Read or Write calls, if any. Retries all state machines |
| 141 | // and, if complete, runs the respective callbacks. |
| 142 | void RetryAllOperations(); |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 143 | |
Jesse Selover | 94c9a94 | 2019-01-16 01:18:04 | [diff] [blame] | 144 | // Callback from the SSL layer when a certificate needs to be verified. This |
| 145 | // is called when establishing new (fresh) connections and when evaluating |
| 146 | // whether an existing session can be resumed. |
| 147 | static ssl_verify_result_t VerifyCertCallback(SSL* ssl, uint8_t* out_alert); |
| 148 | ssl_verify_result_t VerifyCert(); |
| 149 | ssl_verify_result_t HandleVerifyResult(); |
rsleevi | 4a6ca8c | 2016-06-24 03:05:22 | [diff] [blame] | 150 | int VerifyCT(); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 151 | |
[email protected] | 821e3bb | 2013-11-08 01:06:01 | [diff] [blame] | 152 | // Callback from the SSL layer that indicates the remote server is requesting |
| 153 | // a certificate for this client. |
[email protected] | 82c5902 | 2014-08-15 09:38:27 | [diff] [blame] | 154 | int ClientCertRequestCallback(SSL* ssl); |
[email protected] | 821e3bb | 2013-11-08 01:06:01 | [diff] [blame] | 155 | |
davidben | 44aeae6 | 2015-06-24 20:47:43 | [diff] [blame] | 156 | // Called from the SSL layer whenever a new session is established. |
| 157 | int NewSessionCallback(SSL_SESSION* session); |
davidben | dafe4e5 | 2015-04-08 22:53:52 | [diff] [blame] | 158 | |
estark | 723b5eeb | 2016-02-18 21:01:12 | [diff] [blame] | 159 | // Adds the Certificate Transparency info from ct_verify_result_ to |
| 160 | // |ssl_info|. |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 161 | // SCTs are held in three separate vectors in ct_verify_result, each |
| 162 | // vetor representing a particular verification state, this method associates |
| 163 | // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to |
| 164 | // the |ssl_info|.signed_certificate_timestamps list. |
estark | 723b5eeb | 2016-02-18 21:01:12 | [diff] [blame] | 165 | void AddCTInfoToSSLInfo(SSLInfo* ssl_info) const; |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 166 | |
Daniel McArdle | da3fa94 | 2019-02-15 16:41:21 | [diff] [blame] | 167 | // Returns a unique key string for the SSL session cache for this socket. |
rsleevi | f020edc | 2015-03-16 19:31:24 | [diff] [blame] | 168 | std::string GetSessionCacheKey() const; |
| 169 | |
davidben | 421116c | 2015-05-12 19:56:51 | [diff] [blame] | 170 | // Returns true if renegotiations are allowed. |
| 171 | bool IsRenegotiationAllowed() const; |
| 172 | |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 173 | // Returns true when we should be using the ssl_client_session_cache_ |
| 174 | bool IsCachingEnabled() const; |
| 175 | |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 176 | // Callbacks for operations with the private key. |
David Benjamin | b9bafbe | 2017-11-07 21:41:38 | [diff] [blame] | 177 | ssl_private_key_result_t PrivateKeySignCallback(uint8_t* out, |
| 178 | size_t* out_len, |
| 179 | size_t max_out, |
| 180 | uint16_t algorithm, |
| 181 | const uint8_t* in, |
| 182 | size_t in_len); |
davidben | 0bca07fd | 2016-07-18 15:12:03 | [diff] [blame] | 183 | ssl_private_key_result_t PrivateKeyCompleteCallback(uint8_t* out, |
| 184 | size_t* out_len, |
| 185 | size_t max_out); |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 186 | |
davidben | 0bca07fd | 2016-07-18 15:12:03 | [diff] [blame] | 187 | void OnPrivateKeyComplete(Error error, const std::vector<uint8_t>& signature); |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 188 | |
David Benjamin | 7a8e4dfa | 2018-06-12 23:07:21 | [diff] [blame] | 189 | // Called from the BoringSSL info callback. (See |SSL_CTX_set_info_callback|.) |
| 190 | void InfoCallback(int type, int value); |
| 191 | |
davidben | cef9e21 | 2017-04-19 15:00:10 | [diff] [blame] | 192 | // Called whenever BoringSSL processes a protocol message. |
| 193 | void MessageCallback(int is_write, |
| 194 | int content_type, |
| 195 | const void* buf, |
| 196 | size_t len); |
| 197 | |
davidben | 281d13f0 | 2016-04-27 20:43:28 | [diff] [blame] | 198 | void LogConnectEndEvent(int rv); |
| 199 | |
bnc | bd442c2 | 2016-09-14 20:49:16 | [diff] [blame] | 200 | // Record whether ALPN was used, and if so, the negotiated protocol, |
| 201 | // in a UMA histogram. |
| 202 | void RecordNegotiatedProtocol() const; |
bnc | 3cf2a59 | 2016-08-11 14:48:36 | [diff] [blame] | 203 | |
davidben | fe132d9 | 2016-09-27 18:07:21 | [diff] [blame] | 204 | // Returns the net error corresponding to the most recent OpenSSL |
| 205 | // error. ssl_error is the output of SSL_get_error. |
| 206 | int MapLastOpenSSLError(int ssl_error, |
| 207 | const crypto::OpenSSLErrStackTracer& tracer, |
| 208 | OpenSSLErrorInfo* info); |
| 209 | |
Brad Lassey | 3a81417 | 2018-04-26 03:30:21 | [diff] [blame] | 210 | CompletionOnceCallback user_connect_callback_; |
| 211 | CompletionOnceCallback user_read_callback_; |
| 212 | CompletionOnceCallback user_write_callback_; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 213 | |
| 214 | // Used by Read function. |
| 215 | scoped_refptr<IOBuffer> user_read_buf_; |
| 216 | int user_read_buf_len_; |
| 217 | |
| 218 | // Used by Write function. |
| 219 | scoped_refptr<IOBuffer> user_write_buf_; |
| 220 | int user_write_buf_len_; |
Adam Langley | 68df3af | 2019-01-19 00:37:10 | [diff] [blame] | 221 | bool first_post_handshake_write_ = true; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 222 | |
[email protected] | 4b76856 | 2013-02-16 04:10:07 | [diff] [blame] | 223 | // Used by DoPayloadRead() when attempting to fill the caller's buffer with |
| 224 | // as much data as possible without blocking. |
| 225 | // If DoPayloadRead() encounters an error after having read some data, stores |
| 226 | // the result to return on the *next* call to DoPayloadRead(). A value > 0 |
| 227 | // indicates there is no pending result, otherwise 0 indicates EOF and < 0 |
| 228 | // indicates an error. |
| 229 | int pending_read_error_; |
| 230 | |
davidben | b8c2321 | 2014-10-28 00:12:16 | [diff] [blame] | 231 | // If there is a pending read result, the OpenSSL result code (output of |
| 232 | // SSL_get_error) associated with it. |
| 233 | int pending_read_ssl_error_; |
| 234 | |
| 235 | // If there is a pending read result, the OpenSSLErrorInfo associated with it. |
| 236 | OpenSSLErrorInfo pending_read_error_info_; |
| 237 | |
[email protected] | 64b5c89 | 2014-08-08 09:39:26 | [diff] [blame] | 238 | // Set when Connect finishes. |
[email protected] | 170e76c | 2010-10-04 15:04:20 | [diff] [blame] | 239 | scoped_refptr<X509Certificate> server_cert_; |
| 240 | CertVerifyResult server_cert_verify_result_; |
[email protected] | 64b5c89 | 2014-08-08 09:39:26 | [diff] [blame] | 241 | bool completed_connect_; |
[email protected] | 170e76c | 2010-10-04 15:04:20 | [diff] [blame] | 242 | |
[email protected] | 0dc88b3 | 2014-03-26 20:12:28 | [diff] [blame] | 243 | // Set when Read() or Write() successfully reads or writes data to or from the |
| 244 | // network. |
| 245 | bool was_ever_used_; |
| 246 | |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 247 | CertVerifier* const cert_verifier_; |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 248 | std::unique_ptr<CertVerifier::Request> cert_verifier_request_; |
davidben | 09c3d07 | 2014-08-25 20:33:58 | [diff] [blame] | 249 | base::TimeTicks start_cert_verification_time_; |
[email protected] | 170e76c | 2010-10-04 15:04:20 | [diff] [blame] | 250 | |
Jesse Selover | 94c9a94 | 2019-01-16 01:18:04 | [diff] [blame] | 251 | // Result from Cert Verifier. |
| 252 | int cert_verification_result_; |
| 253 | |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 254 | // Certificate Transparency: Verifier and result holder. |
| 255 | ct::CTVerifyResult ct_verify_result_; |
| 256 | CTVerifier* cert_transparency_verifier_; |
| 257 | |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 258 | // OpenSSL stuff |
davidben | d80c12c | 2016-10-11 00:13:49 | [diff] [blame] | 259 | bssl::UniquePtr<SSL> ssl_; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 260 | |
Matt Menke | 841fc41 | 2019-03-05 23:20:12 | [diff] [blame] | 261 | std::unique_ptr<StreamSocket> stream_socket_; |
davidben | 3418e81f | 2016-10-19 00:09:45 | [diff] [blame] | 262 | std::unique_ptr<SocketBIOAdapter> transport_adapter_; |
[email protected] | 055d7f2 | 2010-11-15 12:03:12 | [diff] [blame] | 263 | const HostPortPair host_and_port_; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 264 | SSLConfig ssl_config_; |
Daniel McArdle | 3a663d6 | 2019-01-31 00:48:47 | [diff] [blame] | 265 | // ssl_client_session_cache_ is a non-owning pointer to session cache |
| 266 | SSLClientSessionCache* ssl_client_session_cache_; |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 267 | |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 268 | enum State { |
| 269 | STATE_NONE, |
| 270 | STATE_HANDSHAKE, |
davidben | c4212c0 | 2015-05-12 22:30:18 | [diff] [blame] | 271 | STATE_HANDSHAKE_COMPLETE, |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 272 | }; |
| 273 | State next_handshake_state_; |
svaldez | 4af14d2 | 2015-08-20 13:48:24 | [diff] [blame] | 274 | |
Steven Valdez | 6af02df | 2018-07-15 21:52:33 | [diff] [blame] | 275 | // True if we are currently confirming the handshake. |
| 276 | bool in_confirm_handshake_; |
| 277 | |
svaldez | 4af14d2 | 2015-08-20 13:48:24 | [diff] [blame] | 278 | // True if the socket has been disconnected. |
| 279 | bool disconnected_; |
| 280 | |
bnc | 3cf2a59 | 2016-08-11 14:48:36 | [diff] [blame] | 281 | NextProto negotiated_protocol_; |
davidben | fe132d9 | 2016-09-27 18:07:21 | [diff] [blame] | 282 | // Set to true if a CertificateRequest was received. |
| 283 | bool certificate_requested_; |
[email protected] | 8bd4e7a | 2014-08-09 14:49:17 | [diff] [blame] | 284 | |
davidben | 1d48952 | 2015-07-01 18:48:46 | [diff] [blame] | 285 | int signature_result_; |
| 286 | std::vector<uint8_t> signature_; |
| 287 | |
[email protected] | 8bd4e7a | 2014-08-09 14:49:17 | [diff] [blame] | 288 | TransportSecurityState* transport_security_state_; |
| 289 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 290 | CTPolicyEnforcer* const policy_enforcer_; |
eranm | 6571b2b | 2014-12-03 15:53:23 | [diff] [blame] | 291 | |
[email protected] | 8bd4e7a | 2014-08-09 14:49:17 | [diff] [blame] | 292 | // pinning_failure_log contains a message produced by |
| 293 | // TransportSecurityState::CheckPublicKeyPins in the event of a |
| 294 | // pinning failure. It is a (somewhat) human-readable string. |
| 295 | std::string pinning_failure_log_; |
| 296 | |
dadrian | df302c4 | 2016-06-10 18:48:59 | [diff] [blame] | 297 | // True if PKP is bypassed due to a local trust anchor. |
| 298 | bool pkp_bypassed_; |
| 299 | |
Carlos IL | 8113338 | 2017-12-06 17:18:45 | [diff] [blame] | 300 | // True if there was a certificate error which should be treated as fatal, |
| 301 | // and false otherwise. |
| 302 | bool is_fatal_cert_error_; |
| 303 | |
tfarina | 42834111 | 2016-09-22 13:38:20 | [diff] [blame] | 304 | NetLogWithSource net_log_; |
svaldez | e83af29 | 2016-04-26 14:33:37 | [diff] [blame] | 305 | base::WeakPtrFactory<SSLClientSocketImpl> weak_factory_; |
David Benjamin | e34d7424 | 2017-06-29 20:35:16 | [diff] [blame] | 306 | |
| 307 | DISALLOW_COPY_AND_ASSIGN(SSLClientSocketImpl); |
[email protected] | d518cd9 | 2010-09-29 12:27:44 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | } // namespace net |
| 311 | |
svaldez | e83af29 | 2016-04-26 14:33:37 | [diff] [blame] | 312 | #endif // NET_SOCKET_SSL_CLIENT_SOCKET_IMPL_H_ |