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

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

Issue 135373002: Added SSLHostInfo. Storing of server host info to our standard disk cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 years, 11 months 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 | Annotate | Revision Log
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_NSS_H_ 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_
6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_
7 7
8 #include <certt.h> 8 #include <certt.h>
9 #include <keyt.h> 9 #include <keyt.h>
10 #include <nspr.h> 10 #include <nspr.h>
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 namespace net { 37 namespace net {
38 38
39 class BoundNetLog; 39 class BoundNetLog;
40 class CertVerifier; 40 class CertVerifier;
41 class CTVerifier; 41 class CTVerifier;
42 class ClientSocketHandle; 42 class ClientSocketHandle;
43 class ServerBoundCertService; 43 class ServerBoundCertService;
44 class SingleRequestCertVerifier; 44 class SingleRequestCertVerifier;
45 class SSLHostInfo;
wtc 2014/01/15 19:08:59 This forward declaration is not necessary because
ramant (doing other things) 2014/01/18 00:21:56 Done.
45 class TransportSecurityState; 46 class TransportSecurityState;
46 class X509Certificate; 47 class X509Certificate;
47 48
48 // An SSL client socket implemented with Mozilla NSS. 49 // An SSL client socket implemented with Mozilla NSS.
49 class SSLClientSocketNSS : public SSLClientSocket { 50 class SSLClientSocketNSS : public SSLClientSocket {
50 public: 51 public:
51 // Takes ownership of the |transport_socket|, which must already be connected. 52 // Takes ownership of the |transport_socket|, which must already be connected.
52 // The hostname specified in |host_and_port| will be compared with the name(s) 53 // The hostname specified in |host_and_port| will be compared with the name(s)
53 // in the server's certificate during the SSL handshake. If SSL client 54 // in the server's certificate during the SSL handshake. If SSL client
54 // authentication is requested, the host_and_port field of SSLCertRequestInfo 55 // authentication is requested, the host_and_port field of SSLCertRequestInfo
55 // will be populated with |host_and_port|. |ssl_config| specifies 56 // will be populated with |host_and_port|. |ssl_config| specifies
56 // the SSL settings. 57 // the SSL settings.
57 // 58 //
58 // Because calls to NSS may block, such as due to needing to access slow 59 // Because calls to NSS may block, such as due to needing to access slow
59 // hardware or needing to synchronously unlock protected tokens, calls to 60 // hardware or needing to synchronously unlock protected tokens, calls to
60 // NSS may optionally be run on a dedicated thread. If synchronous/blocking 61 // NSS may optionally be run on a dedicated thread. If synchronous/blocking
61 // behaviour is desired, for performance or compatibility, the current task 62 // behaviour is desired, for performance or compatibility, the current task
62 // runner should be supplied instead. 63 // runner should be supplied instead.
63 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner, 64 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner,
64 scoped_ptr<ClientSocketHandle> transport_socket, 65 scoped_ptr<ClientSocketHandle> transport_socket,
65 const HostPortPair& host_and_port, 66 const HostPortPair& host_and_port,
66 const SSLConfig& ssl_config, 67 const SSLConfig& ssl_config,
68 SSLHostInfo* ssl_host_info,
67 const SSLClientSocketContext& context); 69 const SSLClientSocketContext& context);
68 virtual ~SSLClientSocketNSS(); 70 virtual ~SSLClientSocketNSS();
69 71
70 // SSLClientSocket implementation. 72 // SSLClientSocket implementation.
71 virtual void GetSSLCertRequestInfo( 73 virtual void GetSSLCertRequestInfo(
72 SSLCertRequestInfo* cert_request_info) OVERRIDE; 74 SSLCertRequestInfo* cert_request_info) OVERRIDE;
73 virtual NextProtoStatus GetNextProto(std::string* proto, 75 virtual NextProtoStatus GetNextProto(std::string* proto,
74 std::string* server_protos) OVERRIDE; 76 std::string* server_protos) OVERRIDE;
75 77
76 // SSLSocket implementation. 78 // SSLSocket implementation.
(...skipping 29 matching lines...) Expand all
106 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 108 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
107 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; 109 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE;
108 110
109 private: 111 private:
110 // Helper class to handle marshalling any NSS interaction to and from the 112 // Helper class to handle marshalling any NSS interaction to and from the
111 // NSS and network task runners. Not every call needs to happen on the Core 113 // NSS and network task runners. Not every call needs to happen on the Core
112 class Core; 114 class Core;
113 115
114 enum State { 116 enum State {
115 STATE_NONE, 117 STATE_NONE,
118 STATE_LOAD_SSL_HOST_INFO,
116 STATE_HANDSHAKE, 119 STATE_HANDSHAKE,
117 STATE_HANDSHAKE_COMPLETE, 120 STATE_HANDSHAKE_COMPLETE,
118 STATE_VERIFY_CERT, 121 STATE_VERIFY_CERT,
119 STATE_VERIFY_CERT_COMPLETE, 122 STATE_VERIFY_CERT_COMPLETE,
120 }; 123 };
121 124
122 int Init(); 125 int Init();
123 void InitCore(); 126 void InitCore();
124 127
125 // Initializes NSS SSL options. Returns a net error code. 128 // Initializes NSS SSL options. Returns a net error code.
126 int InitializeSSLOptions(); 129 int InitializeSSLOptions();
127 130
128 // Initializes the socket peer name in SSL. Returns a net error code. 131 // Initializes the socket peer name in SSL. Returns a net error code.
129 int InitializeSSLPeerName(); 132 int InitializeSSLPeerName();
130 133
131 void DoConnectCallback(int result); 134 void DoConnectCallback(int result);
132 void OnHandshakeIOComplete(int result); 135 void OnHandshakeIOComplete(int result);
133 136
137 void LoadSSLHostInfo();
138 int DoLoadSSLHostInfo();
139
134 int DoHandshakeLoop(int last_io_result); 140 int DoHandshakeLoop(int last_io_result);
135 int DoHandshake(); 141 int DoHandshake();
136 int DoHandshakeComplete(int result); 142 int DoHandshakeComplete(int result);
137 int DoVerifyCert(int result); 143 int DoVerifyCert(int result);
138 int DoVerifyCertComplete(int result); 144 int DoVerifyCertComplete(int result);
145 void SaveSSLHostInfo();
139 146
140 void VerifyCT(); 147 void VerifyCT();
141 148
142 void LogConnectionTypeMetrics() const; 149 void LogConnectionTypeMetrics() const;
143 150
144 // The following methods are for debugging bug 65948. Will remove this code 151 // The following methods are for debugging bug 65948. Will remove this code
145 // after fixing bug 65948. 152 // after fixing bug 65948.
146 void EnsureThreadIdAssigned() const; 153 void EnsureThreadIdAssigned() const;
147 bool CalledOnValidThread() const; 154 bool CalledOnValidThread() const;
148 155
149 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|. 156 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|.
150 // SCTs are held in three separate vectors in ct_verify_result, each 157 // SCTs are held in three separate vectors in ct_verify_result, each
151 // vetor representing a particular verification state, this method associates 158 // vetor representing a particular verification state, this method associates
152 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to 159 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to
153 // the |ssl_info|.signed_certificate_timestamps list. 160 // the |ssl_info|.signed_certificate_timestamps list.
154 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const; 161 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const;
155 162
156 // The task runner used to perform NSS operations. 163 // The task runner used to perform NSS operations.
157 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_; 164 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_;
158 scoped_ptr<ClientSocketHandle> transport_; 165 scoped_ptr<ClientSocketHandle> transport_;
159 HostPortPair host_and_port_; 166 HostPortPair host_and_port_;
160 SSLConfig ssl_config_; 167 SSLConfig ssl_config_;
161 168
162 scoped_refptr<Core> core_; 169 scoped_refptr<Core> core_;
163 170
164 CompletionCallback user_connect_callback_; 171 CompletionCallback user_connect_callback_;
165 172
166 CertVerifyResult server_cert_verify_result_; 173 // |server_cert_verify_result_| points at the verification result, which may,
174 // or may not be, |&local_server_cert_verify_result_|, depending on whether
175 // we used an SSLHostInfo's verification.
176 const CertVerifyResult* server_cert_verify_result_;
177 CertVerifyResult local_server_cert_verify_result_;
167 178
168 CertVerifier* const cert_verifier_; 179 CertVerifier* const cert_verifier_;
169 scoped_ptr<SingleRequestCertVerifier> verifier_; 180 scoped_ptr<SingleRequestCertVerifier> verifier_;
170 181
171 // Certificate Transparency: Verifier and result holder. 182 // Certificate Transparency: Verifier and result holder.
172 ct::CTVerifyResult ct_verify_result_; 183 ct::CTVerifyResult ct_verify_result_;
173 CTVerifier* cert_transparency_verifier_; 184 CTVerifier* cert_transparency_verifier_;
174 185
175 // The service for retrieving Channel ID keys. May be NULL. 186 // The service for retrieving Channel ID keys. May be NULL.
176 ServerBoundCertService* server_bound_cert_service_; 187 ServerBoundCertService* server_bound_cert_service_;
(...skipping 10 matching lines...) Expand all
187 198
188 // The NSS SSL state machine. This is owned by |core_|. 199 // The NSS SSL state machine. This is owned by |core_|.
189 // TODO(rsleevi): http://crbug.com/130616 - Remove this member once 200 // TODO(rsleevi): http://crbug.com/130616 - Remove this member once
190 // ExportKeyingMaterial is updated to be asynchronous. 201 // ExportKeyingMaterial is updated to be asynchronous.
191 PRFileDesc* nss_fd_; 202 PRFileDesc* nss_fd_;
192 203
193 BoundNetLog net_log_; 204 BoundNetLog net_log_;
194 205
195 base::TimeTicks start_cert_verification_time_; 206 base::TimeTicks start_cert_verification_time_;
196 207
208 scoped_ptr<SSLHostInfo> ssl_host_info_;
209
197 TransportSecurityState* transport_security_state_; 210 TransportSecurityState* transport_security_state_;
198 211
199 // The following two variables are added for debugging bug 65948. Will 212 // The following two variables are added for debugging bug 65948. Will
200 // remove this code after fixing bug 65948. 213 // remove this code after fixing bug 65948.
201 // Added the following code Debugging in release mode. 214 // Added the following code Debugging in release mode.
202 mutable base::Lock lock_; 215 mutable base::Lock lock_;
203 // This is mutable so that CalledOnValidThread can set it. 216 // This is mutable so that CalledOnValidThread can set it.
204 // It's guarded by |lock_|. 217 // It's guarded by |lock_|.
205 mutable base::PlatformThreadId valid_thread_id_; 218 mutable base::PlatformThreadId valid_thread_id_;
206 }; 219 };
207 220
208 } // namespace net 221 } // namespace net
209 222
210 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ 223 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698