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

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: fixed wtc's comments 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // 57 //
58 // Because calls to NSS may block, such as due to needing to access slow 58 // 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 59 // hardware or needing to synchronously unlock protected tokens, calls to
60 // NSS may optionally be run on a dedicated thread. If synchronous/blocking 60 // NSS may optionally be run on a dedicated thread. If synchronous/blocking
61 // behaviour is desired, for performance or compatibility, the current task 61 // behaviour is desired, for performance or compatibility, the current task
62 // runner should be supplied instead. 62 // runner should be supplied instead.
63 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner, 63 SSLClientSocketNSS(base::SequencedTaskRunner* nss_task_runner,
64 scoped_ptr<ClientSocketHandle> transport_socket, 64 scoped_ptr<ClientSocketHandle> transport_socket,
65 const HostPortPair& host_and_port, 65 const HostPortPair& host_and_port,
66 const SSLConfig& ssl_config, 66 const SSLConfig& ssl_config,
67 SSLHostInfo* ssl_host_info,
67 const SSLClientSocketContext& context); 68 const SSLClientSocketContext& context);
68 virtual ~SSLClientSocketNSS(); 69 virtual ~SSLClientSocketNSS();
69 70
70 // SSLClientSocket implementation. 71 // SSLClientSocket implementation.
71 virtual void GetSSLCertRequestInfo( 72 virtual void GetSSLCertRequestInfo(
72 SSLCertRequestInfo* cert_request_info) OVERRIDE; 73 SSLCertRequestInfo* cert_request_info) OVERRIDE;
73 virtual NextProtoStatus GetNextProto(std::string* proto, 74 virtual NextProtoStatus GetNextProto(std::string* proto,
74 std::string* server_protos) OVERRIDE; 75 std::string* server_protos) OVERRIDE;
75 76
76 // SSLSocket implementation. 77 // SSLSocket implementation.
(...skipping 29 matching lines...) Expand all
106 virtual bool SetSendBufferSize(int32 size) OVERRIDE; 107 virtual bool SetSendBufferSize(int32 size) OVERRIDE;
107 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE; 108 virtual ServerBoundCertService* GetServerBoundCertService() const OVERRIDE;
108 109
109 private: 110 private:
110 // Helper class to handle marshalling any NSS interaction to and from the 111 // 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 112 // NSS and network task runners. Not every call needs to happen on the Core
112 class Core; 113 class Core;
113 114
114 enum State { 115 enum State {
115 STATE_NONE, 116 STATE_NONE,
117 STATE_LOAD_SSL_HOST_INFO,
116 STATE_HANDSHAKE, 118 STATE_HANDSHAKE,
117 STATE_HANDSHAKE_COMPLETE, 119 STATE_HANDSHAKE_COMPLETE,
118 STATE_VERIFY_CERT, 120 STATE_VERIFY_CERT,
119 STATE_VERIFY_CERT_COMPLETE, 121 STATE_VERIFY_CERT_COMPLETE,
120 }; 122 };
121 123
122 int Init(); 124 int Init();
123 void InitCore(); 125 void InitCore();
124 126
125 // Initializes NSS SSL options. Returns a net error code. 127 // Initializes NSS SSL options. Returns a net error code.
126 int InitializeSSLOptions(); 128 int InitializeSSLOptions();
127 129
128 // Initializes the socket peer name in SSL. Returns a net error code. 130 // Initializes the socket peer name in SSL. Returns a net error code.
129 int InitializeSSLPeerName(); 131 int InitializeSSLPeerName();
130 132
131 void DoConnectCallback(int result); 133 void DoConnectCallback(int result);
132 void OnHandshakeIOComplete(int result); 134 void OnHandshakeIOComplete(int result);
133 135
136 void LoadSSLHostInfo();
137 int DoLoadSSLHostInfo();
138
134 int DoHandshakeLoop(int last_io_result); 139 int DoHandshakeLoop(int last_io_result);
135 int DoHandshake(); 140 int DoHandshake();
136 int DoHandshakeComplete(int result); 141 int DoHandshakeComplete(int result);
137 int DoVerifyCert(int result); 142 int DoVerifyCert(int result);
138 int DoVerifyCertComplete(int result); 143 int DoVerifyCertComplete(int result);
144 void SaveSSLHostInfo();
139 145
140 void VerifyCT(); 146 void VerifyCT();
141 147
142 void LogConnectionTypeMetrics() const; 148 void LogConnectionTypeMetrics() const;
143 149
144 // The following methods are for debugging bug 65948. Will remove this code 150 // The following methods are for debugging bug 65948. Will remove this code
145 // after fixing bug 65948. 151 // after fixing bug 65948.
146 void EnsureThreadIdAssigned() const; 152 void EnsureThreadIdAssigned() const;
147 bool CalledOnValidThread() const; 153 bool CalledOnValidThread() const;
148 154
149 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|. 155 // Adds the SignedCertificateTimestamps from ct_verify_result_ to |ssl_info|.
150 // SCTs are held in three separate vectors in ct_verify_result, each 156 // SCTs are held in three separate vectors in ct_verify_result, each
151 // vetor representing a particular verification state, this method associates 157 // vetor representing a particular verification state, this method associates
152 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to 158 // each of the SCTs with the corresponding SCTVerifyStatus as it adds it to
153 // the |ssl_info|.signed_certificate_timestamps list. 159 // the |ssl_info|.signed_certificate_timestamps list.
154 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const; 160 void AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const;
155 161
156 // The task runner used to perform NSS operations. 162 // The task runner used to perform NSS operations.
157 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_; 163 scoped_refptr<base::SequencedTaskRunner> nss_task_runner_;
158 scoped_ptr<ClientSocketHandle> transport_; 164 scoped_ptr<ClientSocketHandle> transport_;
159 HostPortPair host_and_port_; 165 HostPortPair host_and_port_;
160 SSLConfig ssl_config_; 166 SSLConfig ssl_config_;
161 167
162 scoped_refptr<Core> core_; 168 scoped_refptr<Core> core_;
163 169
164 CompletionCallback user_connect_callback_; 170 CompletionCallback user_connect_callback_;
165 171
166 CertVerifyResult server_cert_verify_result_; 172 // |server_cert_verify_result_| points at the verification result, which may,
173 // or may not be, |&local_server_cert_verify_result_|, depending on whether
174 // we used an SSLHostInfo's verification.
175 const CertVerifyResult* server_cert_verify_result_;
176 CertVerifyResult local_server_cert_verify_result_;
167 177
168 CertVerifier* const cert_verifier_; 178 CertVerifier* const cert_verifier_;
169 scoped_ptr<SingleRequestCertVerifier> verifier_; 179 scoped_ptr<SingleRequestCertVerifier> verifier_;
170 180
171 // Certificate Transparency: Verifier and result holder. 181 // Certificate Transparency: Verifier and result holder.
172 ct::CTVerifyResult ct_verify_result_; 182 ct::CTVerifyResult ct_verify_result_;
173 CTVerifier* cert_transparency_verifier_; 183 CTVerifier* cert_transparency_verifier_;
174 184
175 // The service for retrieving Channel ID keys. May be NULL. 185 // The service for retrieving Channel ID keys. May be NULL.
176 ServerBoundCertService* server_bound_cert_service_; 186 ServerBoundCertService* server_bound_cert_service_;
(...skipping 10 matching lines...) Expand all
187 197
188 // The NSS SSL state machine. This is owned by |core_|. 198 // The NSS SSL state machine. This is owned by |core_|.
189 // TODO(rsleevi): http://crbug.com/130616 - Remove this member once 199 // TODO(rsleevi): http://crbug.com/130616 - Remove this member once
190 // ExportKeyingMaterial is updated to be asynchronous. 200 // ExportKeyingMaterial is updated to be asynchronous.
191 PRFileDesc* nss_fd_; 201 PRFileDesc* nss_fd_;
192 202
193 BoundNetLog net_log_; 203 BoundNetLog net_log_;
194 204
195 base::TimeTicks start_cert_verification_time_; 205 base::TimeTicks start_cert_verification_time_;
196 206
207 scoped_ptr<SSLHostInfo> ssl_host_info_;
208
197 TransportSecurityState* transport_security_state_; 209 TransportSecurityState* transport_security_state_;
198 210
199 // The following two variables are added for debugging bug 65948. Will 211 // The following two variables are added for debugging bug 65948. Will
200 // remove this code after fixing bug 65948. 212 // remove this code after fixing bug 65948.
201 // Added the following code Debugging in release mode. 213 // Added the following code Debugging in release mode.
202 mutable base::Lock lock_; 214 mutable base::Lock lock_;
203 // This is mutable so that CalledOnValidThread can set it. 215 // This is mutable so that CalledOnValidThread can set it.
204 // It's guarded by |lock_|. 216 // It's guarded by |lock_|.
205 mutable base::PlatformThreadId valid_thread_id_; 217 mutable base::PlatformThreadId valid_thread_id_;
206 }; 218 };
207 219
208 } // namespace net 220 } // namespace net
209 221
210 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ 222 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698