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

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

Issue 1378613004: Set Token-Binding HTTP header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tb-tls-ext-new
Patch Set: Add UMA logging of Token Binding support and NetLog event for Token Binding key lookup Created 5 years, 1 month 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 (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 <stdint.h> 10 #include <stdint.h>
11 11
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/containers/mru_cache.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "net/base/completion_callback.h" 19 #include "net/base/completion_callback.h"
19 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
20 #include "net/cert/cert_verifier.h" 21 #include "net/cert/cert_verifier.h"
21 #include "net/cert/cert_verify_result.h" 22 #include "net/cert/cert_verify_result.h"
22 #include "net/cert/ct_verify_result.h" 23 #include "net/cert/ct_verify_result.h"
23 #include "net/socket/client_socket_handle.h" 24 #include "net/socket/client_socket_handle.h"
24 #include "net/socket/ssl_client_socket.h" 25 #include "net/socket/ssl_client_socket.h"
25 #include "net/ssl/channel_id_service.h" 26 #include "net/ssl/channel_id_service.h"
26 #include "net/ssl/openssl_ssl_util.h" 27 #include "net/ssl/openssl_ssl_util.h"
27 #include "net/ssl/ssl_client_cert_type.h" 28 #include "net/ssl/ssl_client_cert_type.h"
28 #include "net/ssl/ssl_config_service.h" 29 #include "net/ssl/ssl_config_service.h"
29 #include "net/ssl/ssl_failure_state.h" 30 #include "net/ssl/ssl_failure_state.h"
30 31
31 namespace net { 32 namespace net {
32 33
33 class CertVerifier; 34 class CertVerifier;
34 class CTVerifier; 35 class CTVerifier;
35 class SSLCertRequestInfo; 36 class SSLCertRequestInfo;
36 class SSLInfo; 37 class SSLInfo;
37 class SSLPrivateKey; 38 class SSLPrivateKey;
38 39
40 typedef base::MRUCache<std::string, std::vector<uint8_t>> SignedEkmMap;
41
39 // An SSL client socket implemented with OpenSSL. 42 // An SSL client socket implemented with OpenSSL.
40 class SSLClientSocketOpenSSL : public SSLClientSocket { 43 class SSLClientSocketOpenSSL : public SSLClientSocket {
41 public: 44 public:
42 // Takes ownership of the transport_socket, which may already be connected. 45 // Takes ownership of the transport_socket, which may already be connected.
43 // The given hostname will be compared with the name(s) in the server's 46 // The given hostname will be compared with the name(s) in the server's
44 // certificate during the SSL handshake. ssl_config specifies the SSL 47 // certificate during the SSL handshake. ssl_config specifies the SSL
45 // settings. 48 // settings.
46 SSLClientSocketOpenSSL(scoped_ptr<ClientSocketHandle> transport_socket, 49 SSLClientSocketOpenSSL(scoped_ptr<ClientSocketHandle> transport_socket,
47 const HostPortPair& host_and_port, 50 const HostPortPair& host_and_port,
48 const SSLConfig& ssl_config, 51 const SSLConfig& ssl_config,
49 const SSLClientSocketContext& context); 52 const SSLClientSocketContext& context);
50 ~SSLClientSocketOpenSSL() override; 53 ~SSLClientSocketOpenSSL() override;
51 54
52 const HostPortPair& host_and_port() const { return host_and_port_; } 55 const HostPortPair& host_and_port() const { return host_and_port_; }
53 const std::string& ssl_session_cache_shard() const { 56 const std::string& ssl_session_cache_shard() const {
54 return ssl_session_cache_shard_; 57 return ssl_session_cache_shard_;
55 } 58 }
56 59
57 // Export ssl key log files if env variable is not set. 60 // Export ssl key log files if env variable is not set.
58 static void SetSSLKeyLogFile(const std::string& ssl_keylog_file); 61 static void SetSSLKeyLogFile(const std::string& ssl_keylog_file);
59 62
60 // SSLClientSocket implementation. 63 // SSLClientSocket implementation.
61 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; 64 void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override;
62 NextProtoStatus GetNextProto(std::string* proto) const override; 65 NextProtoStatus GetNextProto(std::string* proto) const override;
63 ChannelIDService* GetChannelIDService() const override; 66 ChannelIDService* GetChannelIDService() const override;
67 int GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key,
68 std::vector<uint8_t>* out) override;
64 SSLFailureState GetSSLFailureState() const override; 69 SSLFailureState GetSSLFailureState() const override;
65 70
66 // SSLSocket implementation. 71 // SSLSocket implementation.
67 int ExportKeyingMaterial(const base::StringPiece& label, 72 int ExportKeyingMaterial(const base::StringPiece& label,
68 bool has_context, 73 bool has_context,
69 const base::StringPiece& context, 74 const base::StringPiece& context,
70 unsigned char* out, 75 unsigned char* out,
71 unsigned int outlen) override; 76 unsigned int outlen) override;
72 int GetTLSUniqueChannelBinding(std::string* out) override; 77 int GetTLSUniqueChannelBinding(std::string* out) override;
73 78
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 base::TimeTicks start_cert_verification_time_; 288 base::TimeTicks start_cert_verification_time_;
284 289
285 // Certificate Transparency: Verifier and result holder. 290 // Certificate Transparency: Verifier and result holder.
286 ct::CTVerifyResult ct_verify_result_; 291 ct::CTVerifyResult ct_verify_result_;
287 CTVerifier* cert_transparency_verifier_; 292 CTVerifier* cert_transparency_verifier_;
288 293
289 // The service for retrieving Channel ID keys. May be NULL. 294 // The service for retrieving Channel ID keys. May be NULL.
290 ChannelIDService* channel_id_service_; 295 ChannelIDService* channel_id_service_;
291 bool tb_was_negotiated_; 296 bool tb_was_negotiated_;
292 TokenBindingParam tb_negotiated_param_; 297 TokenBindingParam tb_negotiated_param_;
298 SignedEkmMap tb_signed_ekm_map_;
293 299
294 // OpenSSL stuff 300 // OpenSSL stuff
295 SSL* ssl_; 301 SSL* ssl_;
296 BIO* transport_bio_; 302 BIO* transport_bio_;
297 303
298 scoped_ptr<ClientSocketHandle> transport_; 304 scoped_ptr<ClientSocketHandle> transport_;
299 const HostPortPair host_and_port_; 305 const HostPortPair host_and_port_;
300 SSLConfig ssl_config_; 306 SSLConfig ssl_config_;
301 // ssl_session_cache_shard_ is an opaque string that partitions the SSL 307 // ssl_session_cache_shard_ is an opaque string that partitions the SSL
302 // session cache. i.e. sessions created with one value will not attempt to 308 // session cache. i.e. sessions created with one value will not attempt to
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // pinning failure. It is a (somewhat) human-readable string. 352 // pinning failure. It is a (somewhat) human-readable string.
347 std::string pinning_failure_log_; 353 std::string pinning_failure_log_;
348 354
349 BoundNetLog net_log_; 355 BoundNetLog net_log_;
350 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_; 356 base::WeakPtrFactory<SSLClientSocketOpenSSL> weak_factory_;
351 }; 357 };
352 358
353 } // namespace net 359 } // namespace net
354 360
355 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_ 361 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_OPENSSL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698