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 <openssl/base.h> | 8 #include <openssl/base.h> |
9 #include <openssl/ssl.h> | 9 #include <openssl/ssl.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
| 16 #include "base/compiler_specific.h" |
| 17 #include "base/containers/mru_cache.h" |
16 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
19 #include "build/build_config.h" | 21 #include "build/build_config.h" |
20 #include "net/base/completion_callback.h" | 22 #include "net/base/completion_callback.h" |
21 #include "net/base/io_buffer.h" | 23 #include "net/base/io_buffer.h" |
22 #include "net/cert/cert_verifier.h" | 24 #include "net/cert/cert_verifier.h" |
23 #include "net/cert/cert_verify_result.h" | 25 #include "net/cert/cert_verify_result.h" |
24 #include "net/cert/ct_verify_result.h" | 26 #include "net/cert/ct_verify_result.h" |
25 #include "net/socket/client_socket_handle.h" | 27 #include "net/socket/client_socket_handle.h" |
26 #include "net/socket/ssl_client_socket.h" | 28 #include "net/socket/ssl_client_socket.h" |
27 #include "net/ssl/channel_id_service.h" | 29 #include "net/ssl/channel_id_service.h" |
28 #include "net/ssl/openssl_ssl_util.h" | 30 #include "net/ssl/openssl_ssl_util.h" |
29 #include "net/ssl/ssl_client_cert_type.h" | 31 #include "net/ssl/ssl_client_cert_type.h" |
30 #include "net/ssl/ssl_config_service.h" | 32 #include "net/ssl/ssl_config_service.h" |
31 #include "net/ssl/ssl_failure_state.h" | 33 #include "net/ssl/ssl_failure_state.h" |
32 | 34 |
33 namespace base { | 35 namespace base { |
34 class FilePath; | 36 class FilePath; |
35 class SequencedTaskRunner; | 37 class SequencedTaskRunner; |
36 } | 38 } |
37 | 39 |
38 namespace net { | 40 namespace net { |
39 | 41 |
40 class CertVerifier; | 42 class CertVerifier; |
41 class CTVerifier; | 43 class CTVerifier; |
42 class SSLCertRequestInfo; | 44 class SSLCertRequestInfo; |
43 class SSLInfo; | 45 class SSLInfo; |
44 | 46 |
| 47 using SignedEkmMap = base::MRUCache<std::string, std::vector<uint8_t>>; |
| 48 |
45 // An SSL client socket implemented with OpenSSL. | 49 // An SSL client socket implemented with OpenSSL. |
46 class SSLClientSocketOpenSSL : public SSLClientSocket { | 50 class SSLClientSocketOpenSSL : public SSLClientSocket { |
47 public: | 51 public: |
48 // Takes ownership of the transport_socket, which may already be connected. | 52 // Takes ownership of the transport_socket, which may already be connected. |
49 // The given hostname will be compared with the name(s) in the server's | 53 // The given hostname will be compared with the name(s) in the server's |
50 // certificate during the SSL handshake. ssl_config specifies the SSL | 54 // certificate during the SSL handshake. ssl_config specifies the SSL |
51 // settings. | 55 // settings. |
52 SSLClientSocketOpenSSL(scoped_ptr<ClientSocketHandle> transport_socket, | 56 SSLClientSocketOpenSSL(scoped_ptr<ClientSocketHandle> transport_socket, |
53 const HostPortPair& host_and_port, | 57 const HostPortPair& host_and_port, |
54 const SSLConfig& ssl_config, | 58 const SSLConfig& ssl_config, |
(...skipping 10 matching lines...) Expand all Loading... |
65 // SSLClientSockets are created. | 69 // SSLClientSockets are created. |
66 static void SetSSLKeyLogFile( | 70 static void SetSSLKeyLogFile( |
67 const base::FilePath& path, | 71 const base::FilePath& path, |
68 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 72 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
69 #endif | 73 #endif |
70 | 74 |
71 // SSLClientSocket implementation. | 75 // SSLClientSocket implementation. |
72 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; | 76 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
73 NextProtoStatus GetNextProto(std::string* proto) const override; | 77 NextProtoStatus GetNextProto(std::string* proto) const override; |
74 ChannelIDService* GetChannelIDService() const override; | 78 ChannelIDService* GetChannelIDService() const override; |
| 79 Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 80 std::vector<uint8_t>* out) override; |
75 SSLFailureState GetSSLFailureState() const override; | 81 SSLFailureState GetSSLFailureState() const override; |
76 | 82 |
77 // SSLSocket implementation. | 83 // SSLSocket implementation. |
78 int ExportKeyingMaterial(const base::StringPiece& label, | 84 int ExportKeyingMaterial(const base::StringPiece& label, |
79 bool has_context, | 85 bool has_context, |
80 const base::StringPiece& context, | 86 const base::StringPiece& context, |
81 unsigned char* out, | 87 unsigned char* out, |
82 unsigned int outlen) override; | 88 unsigned int outlen) override; |
83 int GetTLSUniqueChannelBinding(std::string* out) override; | 89 int GetTLSUniqueChannelBinding(std::string* out) override; |
84 | 90 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 base::TimeTicks start_cert_verification_time_; | 300 base::TimeTicks start_cert_verification_time_; |
295 | 301 |
296 // Certificate Transparency: Verifier and result holder. | 302 // Certificate Transparency: Verifier and result holder. |
297 ct::CTVerifyResult ct_verify_result_; | 303 ct::CTVerifyResult ct_verify_result_; |
298 CTVerifier* cert_transparency_verifier_; | 304 CTVerifier* cert_transparency_verifier_; |
299 | 305 |
300 // The service for retrieving Channel ID keys. May be NULL. | 306 // The service for retrieving Channel ID keys. May be NULL. |
301 ChannelIDService* channel_id_service_; | 307 ChannelIDService* channel_id_service_; |
302 bool tb_was_negotiated_; | 308 bool tb_was_negotiated_; |
303 TokenBindingParam tb_negotiated_param_; | 309 TokenBindingParam tb_negotiated_param_; |
| 310 SignedEkmMap tb_signed_ekm_map_; |
304 | 311 |
305 // OpenSSL stuff | 312 // OpenSSL stuff |
306 SSL* ssl_; | 313 SSL* ssl_; |
307 BIO* transport_bio_; | 314 BIO* transport_bio_; |
308 | 315 |
309 scoped_ptr<ClientSocketHandle> transport_; | 316 scoped_ptr<ClientSocketHandle> transport_; |
310 const HostPortPair host_and_port_; | 317 const HostPortPair host_and_port_; |
311 SSLConfig ssl_config_; | 318 SSLConfig ssl_config_; |
312 // ssl_session_cache_shard_ is an opaque string that partitions the SSL | 319 // ssl_session_cache_shard_ is an opaque string that partitions the SSL |
313 // session cache. i.e. sessions created with one value will not attempt to | 320 // session cache. i.e. sessions created with one value will not attempt to |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // pinning failure. It is a (somewhat) human-readable string. | 363 // pinning failure. It is a (somewhat) human-readable string. |
357 std::string pinning_failure_log_; | 364 std::string pinning_failure_log_; |
358 | 365 |
359 BoundNetLog net_log_; | 366 BoundNetLog net_log_; |
360 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; | 367 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; |
361 }; | 368 }; |
362 | 369 |
363 } // namespace net | 370 } // namespace net |
364 | 371 |
365 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ | 372 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ |
OLD | NEW |