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

Side by Side Diff: net/http/http_proxy_client_socket_pool.cc

Issue 4339001: Correctly handle SSL Client Authentication requests when connecting... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "net/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 Delegate* delegate, 75 Delegate* delegate,
76 NetLog* net_log) 76 NetLog* net_log)
77 : ConnectJob(group_name, timeout_duration, delegate, 77 : ConnectJob(group_name, timeout_duration, delegate,
78 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), 78 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
79 params_(params), 79 params_(params),
80 tcp_pool_(tcp_pool), 80 tcp_pool_(tcp_pool),
81 ssl_pool_(ssl_pool), 81 ssl_pool_(ssl_pool),
82 resolver_(host_resolver), 82 resolver_(host_resolver),
83 ALLOW_THIS_IN_INITIALIZER_LIST( 83 ALLOW_THIS_IN_INITIALIZER_LIST(
84 callback_(this, &HttpProxyConnectJob::OnIOComplete)), 84 callback_(this, &HttpProxyConnectJob::OnIOComplete)),
85 using_spdy_(false) { 85 using_spdy_(false),
86 error_response_info_() {
wtc 2010/11/11 01:11:35 Remove this. We usually omit this kind of member
Ryan Hamilton 2010/11/11 18:57:00 Done.
86 } 87 }
87 88
88 HttpProxyConnectJob::~HttpProxyConnectJob() {} 89 HttpProxyConnectJob::~HttpProxyConnectJob() {}
89 90
90 LoadState HttpProxyConnectJob::GetLoadState() const { 91 LoadState HttpProxyConnectJob::GetLoadState() const {
91 switch (next_state_) { 92 switch (next_state_) {
92 case STATE_TCP_CONNECT: 93 case STATE_TCP_CONNECT:
93 case STATE_TCP_CONNECT_COMPLETE: 94 case STATE_TCP_CONNECT_COMPLETE:
94 case STATE_SSL_CONNECT: 95 case STATE_SSL_CONNECT:
95 case STATE_SSL_CONNECT_COMPLETE: 96 case STATE_SSL_CONNECT_COMPLETE:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 201 }
201 next_state_ = STATE_SSL_CONNECT_COMPLETE; 202 next_state_ = STATE_SSL_CONNECT_COMPLETE;
202 transport_socket_handle_.reset(new ClientSocketHandle()); 203 transport_socket_handle_.reset(new ClientSocketHandle());
203 return transport_socket_handle_->Init( 204 return transport_socket_handle_->Init(
204 group_name(), params_->ssl_params(), 205 group_name(), params_->ssl_params(),
205 params_->ssl_params()->tcp_params()->destination().priority(), 206 params_->ssl_params()->tcp_params()->destination().priority(),
206 &callback_, ssl_pool_, net_log()); 207 &callback_, ssl_pool_, net_log());
207 } 208 }
208 209
209 int HttpProxyConnectJob::DoSSLConnectComplete(int result) { 210 int HttpProxyConnectJob::DoSSLConnectComplete(int result) {
210 // TODO(rch): enable support for client auth to the proxy 211 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) {
211 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) 212 error_response_info_ = transport_socket_handle_->ssl_error_response_info();
212 return ERR_PROXY_AUTH_UNSUPPORTED; 213 DCHECK(error_response_info_.cert_request_info.get());
214 return ERR_SSL_CLIENT_AUTH_CERT_NEEDED;
wtc 2010/11/11 01:11:35 You can just return 'result' now.
Ryan Hamilton 2010/11/11 18:57:00 Done.
215 }
213 if (IsCertificateError(result)) { 216 if (IsCertificateError(result)) {
214 if (params_->ssl_params()->load_flags() & LOAD_IGNORE_ALL_CERT_ERRORS) 217 if (params_->ssl_params()->load_flags() & LOAD_IGNORE_ALL_CERT_ERRORS)
215 result = OK; 218 result = OK;
216 else 219 else
217 // TODO(rch): allow the user to deal with proxy cert errors in the 220 // TODO(rch): allow the user to deal with proxy cert errors in the
218 // same way as server cert errors. 221 // same way as server cert errors.
219 return ERR_PROXY_CERTIFICATE_INVALID; 222 return ERR_PROXY_CERTIFICATE_INVALID;
220 } 223 }
221 if (result < 0) { 224 if (result < 0) {
222 if (transport_socket_handle_->socket()) 225 if (transport_socket_handle_->socket())
223 transport_socket_handle_->socket()->Disconnect(); 226 transport_socket_handle_->socket()->Disconnect();
224 return ERR_PROXY_CONNECTION_FAILED; 227 return ERR_PROXY_CONNECTION_FAILED;
225 } 228 }
226 229
227 SSLClientSocket* ssl = 230 SSLClientSocket* ssl =
228 static_cast<SSLClientSocket*>(transport_socket_handle_->socket()); 231 static_cast<SSLClientSocket*>(transport_socket_handle_->socket());
229 using_spdy_ = ssl->was_spdy_negotiated(); 232 using_spdy_ = ssl->was_spdy_negotiated();
230 233
231 // Reset the timer to just the length of time allowed for HttpProxy handshake 234 // Reset the timer to just the length of time allowed for HttpProxy handshake
232 // so that a fast SSL connection plus a slow HttpProxy failure doesn't take 235 // so that a fast SSL connection plus a slow HttpProxy failure doesn't take
233 // longer to timeout than it should. 236 // longer to timeout than it should.
234 ResetTimer(base::TimeDelta::FromSeconds( 237 ResetTimer(base::TimeDelta::FromSeconds(
235 kHttpProxyConnectJobTimeoutInSeconds)); 238 kHttpProxyConnectJobTimeoutInSeconds));
236 // TODO(rch): If we ever decide to implement a "trusted" SPDY proxy 239 // TODO(rch): If we ever decide to implement a "trusted" SPDY proxy
237 // (one that we speak SPDY over SSL to, but to which we send HTTPS 240 // (one that we speak SPDY over SSL to, but to which we send HTTPS
238 // request directly instead of through CONNECT tunnels, then we 241 // request directly instead of through CONNECT tunnels, then we
239 // need to add a predicate to this if statement so we fall through 242 // need to add a predicate to this if statement so we fall through
240 // to the else case. (HttpProxyClientSocket currently acts as 243 // to the else case. (HttpProxyClientSocket currently acts as
241 // a "trusted" SPDY proxy). 244 // a "trusted" SPDY proxy).
245 LOG(INFO) << "Connected to HTTPS proxy, using spdy: " << (using_spdy_ ? "yes" : "no");
wtc 2010/11/11 01:11:35 Use VLOG(1) instead of LOG(INFO). This line seems
Ryan Hamilton 2010/11/11 18:57:00 Removed this line.
242 if (using_spdy_ && params_->tunnel()) 246 if (using_spdy_ && params_->tunnel())
243 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; 247 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM;
244 else 248 else
245 next_state_ = STATE_HTTP_PROXY_CONNECT; 249 next_state_ = STATE_HTTP_PROXY_CONNECT;
246 return result; 250 return result;
247 } 251 }
248 252
253 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) {
254 if (error_response_info_.cert_request_info) {
255 handle->set_ssl_error_response_info(error_response_info_);
256 handle->set_is_ssl_error(true);
257 }
258 }
259
249 int HttpProxyConnectJob::DoSpdyProxyCreateStream() { 260 int HttpProxyConnectJob::DoSpdyProxyCreateStream() {
250 DCHECK(using_spdy_); 261 DCHECK(using_spdy_);
251 DCHECK(params_->tunnel()); 262 DCHECK(params_->tunnel());
252 263
253 HostPortProxyPair pair(params_->destination().host_port_pair(), 264 HostPortProxyPair pair(params_->destination().host_port_pair(),
254 ProxyServer::Direct()); 265 ProxyServer::Direct());
255 SpdySessionPool* spdy_pool = params_->spdy_session_pool(); 266 SpdySessionPool* spdy_pool = params_->spdy_session_pool();
256 scoped_refptr<SpdySession> spdy_session; 267 scoped_refptr<SpdySession> spdy_session;
257 // It's possible that a session to the proxy has recently been created 268 // It's possible that a session to the proxy has recently been created
258 if (spdy_pool->HasSession(pair)) { 269 if (spdy_pool->HasSession(pair)) {
259 if (transport_socket_handle_->socket()) 270 if (transport_socket_handle_.get()) {
wtc 2010/11/11 01:11:35 Can you explain why you need the null pointer chec
Ryan Hamilton 2010/11/11 18:57:00 Yes. If HttpProxyClientSocket::Connect() is calle
260 transport_socket_handle_->socket()->Disconnect(); 271 if (transport_socket_handle_->socket())
261 transport_socket_handle_->Reset(); 272 transport_socket_handle_->socket()->Disconnect();
273 transport_socket_handle_->Reset();
274 }
262 spdy_session = spdy_pool->Get(pair, params_->spdy_settings(), net_log()); 275 spdy_session = spdy_pool->Get(pair, params_->spdy_settings(), net_log());
263 } else { 276 } else {
264 // Create a session direct to the proxy itself 277 // Create a session direct to the proxy itself
265 int rv = spdy_pool->GetSpdySessionFromSocket( 278 int rv = spdy_pool->GetSpdySessionFromSocket(
266 pair, params_->spdy_settings(), transport_socket_handle_.release(), 279 pair, params_->spdy_settings(), transport_socket_handle_.release(),
267 net_log(), OK, &spdy_session, /*using_ssl_*/ true); 280 net_log(), OK, &spdy_session, /*using_ssl_*/ true);
268 if (rv < 0) { 281 if (rv < 0) {
269 if (transport_socket_handle_->socket()) 282 if (transport_socket_handle_->socket())
wtc 2010/11/11 01:11:35 I pointed this out before: after the transport_soc
Ryan Hamilton 2010/11/11 18:57:00 Nice catch! It turns out the SpdySession destruct
wtc 2010/11/12 00:12:55 Good. Please remove the curly braces as well.
Ryan Hamilton 2010/11/12 00:47:30 Done.
270 transport_socket_handle_->socket()->Disconnect(); 283 transport_socket_handle_->socket()->Disconnect();
271 return rv; 284 return rv;
272 } 285 }
273 } 286 }
274 287
275 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; 288 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE;
276 return spdy_session->CreateStream(params_->request_url(), 289 return spdy_session->CreateStream(params_->request_url(),
277 params_->destination().priority(), 290 params_->destination().priority(),
278 &spdy_stream_, net_log(), &callback_); 291 &spdy_stream_, net_log(), &callback_);
279 } 292 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 list->Append(ssl_pool_->GetInfoAsValue("ssl_socket_pool", 452 list->Append(ssl_pool_->GetInfoAsValue("ssl_socket_pool",
440 "ssl_socket_pool", 453 "ssl_socket_pool",
441 true)); 454 true));
442 } 455 }
443 dict->Set("nested_pools", list); 456 dict->Set("nested_pools", list);
444 } 457 }
445 return dict; 458 return dict;
446 } 459 }
447 460
448 } // namespace net 461 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698