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

Side by Side Diff: net/quic/quic_client_session.cc

Issue 355293003: Restrict QUIC session pool when channel ID is present. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 #include "net/quic/quic_client_session.h" 5 #include "net/quic/quic_client_session.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/sparse_histogram.h" 10 #include "base/metrics/sparse_histogram.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/quic/crypto/proof_verifier_chromium.h" 16 #include "net/quic/crypto/proof_verifier_chromium.h"
17 #include "net/quic/crypto/quic_server_info.h" 17 #include "net/quic/crypto/quic_server_info.h"
18 #include "net/quic/quic_connection_helper.h" 18 #include "net/quic/quic_connection_helper.h"
19 #include "net/quic/quic_crypto_client_stream_factory.h" 19 #include "net/quic/quic_crypto_client_stream_factory.h"
20 #include "net/quic/quic_default_packet_writer.h" 20 #include "net/quic/quic_default_packet_writer.h"
21 #include "net/quic/quic_server_id.h" 21 #include "net/quic/quic_server_id.h"
22 #include "net/quic/quic_stream_factory.h" 22 #include "net/quic/quic_stream_factory.h"
23 #include "net/ssl/server_bound_cert_service.h"
23 #include "net/ssl/ssl_connection_status_flags.h" 24 #include "net/ssl/ssl_connection_status_flags.h"
24 #include "net/ssl/ssl_info.h" 25 #include "net/ssl/ssl_info.h"
25 #include "net/udp/datagram_client_socket.h" 26 #include "net/udp/datagram_client_socket.h"
26 27
27 namespace net { 28 namespace net {
28 29
29 namespace { 30 namespace {
30 31
31 // The length of time to wait for a 0-RTT handshake to complete 32 // The length of time to wait for a 0-RTT handshake to complete
32 // before allowing the requests to possibly proceed over TCP. 33 // before allowing the requests to possibly proceed over TCP.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 *stream_ = stream; 126 *stream_ = stream;
126 ResetAndReturn(&callback_).Run(OK); 127 ResetAndReturn(&callback_).Run(OK);
127 } 128 }
128 129
129 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) { 130 void QuicClientSession::StreamRequest::OnRequestCompleteFailure(int rv) {
130 session_.reset(); 131 session_.reset();
131 ResetAndReturn(&callback_).Run(rv); 132 ResetAndReturn(&callback_).Run(rv);
132 } 133 }
133 134
134 QuicClientSession::QuicClientSession( 135 QuicClientSession::QuicClientSession(
136 const HostPortPair& host_port_pair,
135 QuicConnection* connection, 137 QuicConnection* connection,
136 scoped_ptr<DatagramClientSocket> socket, 138 scoped_ptr<DatagramClientSocket> socket,
137 scoped_ptr<QuicDefaultPacketWriter> writer, 139 scoped_ptr<QuicDefaultPacketWriter> writer,
138 QuicStreamFactory* stream_factory, 140 QuicStreamFactory* stream_factory,
139 QuicCryptoClientStreamFactory* crypto_client_stream_factory, 141 QuicCryptoClientStreamFactory* crypto_client_stream_factory,
140 scoped_ptr<QuicServerInfo> server_info, 142 scoped_ptr<QuicServerInfo> server_info,
141 const QuicServerId& server_id, 143 const QuicServerId& server_id,
142 const QuicConfig& config, 144 const QuicConfig& config,
143 QuicCryptoClientConfig* crypto_config, 145 QuicCryptoClientConfig* crypto_config,
144 base::TaskRunner* task_runner, 146 base::TaskRunner* task_runner,
145 NetLog* net_log) 147 NetLog* net_log)
146 : QuicClientSessionBase(connection, 148 : QuicClientSessionBase(connection,
147 config), 149 config),
150 host_port_pair_(host_port_pair),
148 require_confirmation_(false), 151 require_confirmation_(false),
149 stream_factory_(stream_factory), 152 stream_factory_(stream_factory),
150 socket_(socket.Pass()), 153 socket_(socket.Pass()),
151 writer_(writer.Pass()), 154 writer_(writer.Pass()),
152 read_buffer_(new IOBufferWithSize(kMaxPacketSize)), 155 read_buffer_(new IOBufferWithSize(kMaxPacketSize)),
153 server_info_(server_info.Pass()), 156 server_info_(server_info.Pass()),
154 read_pending_(false), 157 read_pending_(false),
155 num_total_streams_(0), 158 num_total_streams_(0),
156 task_runner_(task_runner), 159 task_runner_(task_runner),
157 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), 160 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 475
473 callback_ = callback; 476 callback_ = callback;
474 return ERR_IO_PENDING; 477 return ERR_IO_PENDING;
475 } 478 }
476 479
477 int QuicClientSession::GetNumSentClientHellos() const { 480 int QuicClientSession::GetNumSentClientHellos() const {
478 return crypto_stream_->num_sent_client_hellos(); 481 return crypto_stream_->num_sent_client_hellos();
479 } 482 }
480 483
481 bool QuicClientSession::CanPool(const std::string& hostname) const { 484 bool QuicClientSession::CanPool(const std::string& hostname) const {
482 // TODO(rch): When QUIC supports channel ID or client certificates, this
483 // logic will need to be revised.
484 DCHECK(connection()->connected()); 485 DCHECK(connection()->connected());
485 SSLInfo ssl_info; 486 SSLInfo ssl_info;
486 bool unused = false;
487 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) { 487 if (!GetSSLInfo(&ssl_info) || !ssl_info.cert) {
488 // We can always pool with insecure QUIC sessions. 488 // We can always pool with insecure QUIC sessions.
489 return true; 489 return true;
490 } 490 }
491 // Only pool secure QUIC sessions if the cert matches the new hostname. 491
492 return ssl_info.cert->VerifyNameMatch(hostname, &unused); 492 bool unused = false;
493 return
494 !ssl_info.client_cert_sent &&
495 (!ssl_info.channel_id_sent ||
496 (ServerBoundCertService::GetDomainForHost(hostname) ==
497 ServerBoundCertService::GetDomainForHost(host_port_pair_.host()))) &&
498 ssl_info.cert->VerifyNameMatch(hostname, &unused);
wtc 2014/06/27 23:55:51 Nit: a comment that summerizes this complicated co
Ryan Hamilton 2014/07/01 18:37:17 Done. Would you prefer a series of early returns:
wtc 2014/07/01 23:00:14 Yes, I also wanted to suggest that :-) One reason
Ryan Hamilton 2014/07/01 23:26:19 Done.
493 } 499 }
494 500
495 QuicDataStream* QuicClientSession::CreateIncomingDataStream( 501 QuicDataStream* QuicClientSession::CreateIncomingDataStream(
496 QuicStreamId id) { 502 QuicStreamId id) {
497 DLOG(ERROR) << "Server push not supported"; 503 DLOG(ERROR) << "Server push not supported";
498 return NULL; 504 return NULL;
499 } 505 }
500 506
501 void QuicClientSession::CloseStream(QuicStreamId stream_id) { 507 void QuicClientSession::CloseStream(QuicStreamId stream_id) {
502 ReliableQuicStream* stream = GetStream(stream_id); 508 ReliableQuicStream* stream = GetStream(stream_id);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 return; 843 return;
838 844
839 // TODO(rch): re-enable this code once beta is cut. 845 // TODO(rch): re-enable this code once beta is cut.
840 // if (stream_factory_) 846 // if (stream_factory_)
841 // stream_factory_->OnSessionConnectTimeout(this); 847 // stream_factory_->OnSessionConnectTimeout(this);
842 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED); 848 // CloseAllStreams(ERR_QUIC_HANDSHAKE_FAILED);
843 // DCHECK_EQ(0u, GetNumOpenStreams()); 849 // DCHECK_EQ(0u, GetNumOpenStreams());
844 } 850 }
845 851
846 } // namespace net 852 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698