Index: net/http/http_stream_factory_impl_job.cc |
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc |
index 78f4eedb1a19300346cca7428e756a73c41d2279..f47881fe74408811bbf409fc6b2b400967b8f559 100644 |
--- a/net/http/http_stream_factory_impl_job.cc |
+++ b/net/http/http_stream_factory_impl_job.cc |
@@ -292,6 +292,18 @@ bool HttpStreamFactoryImpl::Job::CanUseExistingSpdySession() const { |
proxy_info_.proxy_server().is_https() || IsSpdyAlternate(); |
} |
+bool HttpStreamFactoryImpl::Job::IsAlternativeCertificateValidForOrigin( |
+ base::WeakPtr<SpdySession> spdy_session) { |
+ DCHECK(spdy_session); |
+ if (!using_ssl_) { |
+ return true; |
Ryan Hamilton
2015/04/10 18:37:37
We only speak SPDY over TLS, right? I think this c
Bence
2015/04/10 19:55:16
Well, not quite, this member was called for non-ss
|
+ } |
+ if (origin_url_.host() == spdy_session->host_port_pair().host()) { |
Ryan Hamilton
2015/04/10 18:37:36
It seems that this is simply a performance optimiz
Bence
2015/04/10 19:55:16
Not exactly. I added this test here because other
Ryan Hamilton
2015/04/11 02:40:41
Ah. I'm not a big fan of having "real" code that's
Bence
2015/04/13 17:52:40
I totally agree with you. It turns out that there
Ryan Hamilton
2015/04/13 18:29:56
It seems like it should be pretty easy to add a he
Bence
2015/04/15 21:07:46
Done.
|
+ return true; |
+ } |
+ return spdy_session->VerifyDomainAuthentication(origin_url_.host()); |
+} |
+ |
void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
DCHECK(stream_.get()); |
DCHECK(!IsPreconnecting()); |
@@ -457,7 +469,8 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
return ERR_IO_PENDING; |
} |
- if (IsCertificateError(result)) { |
+ if (IsCertificateError(result) && |
+ result != ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN) { |
Ryan Hamilton
2015/04/10 18:37:37
Yeah, definitely move this error out of the certif
Bence
2015/04/10 19:55:16
Done.
|
// Retrieve SSL information from the socket. |
GetSSLInfo(); |
@@ -535,6 +548,20 @@ int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
} |
return ERR_IO_PENDING; |
+ case ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN: |
Ryan Hamilton
2015/04/10 18:37:36
This should only happen for a job that IsAlternate
Bence
2015/04/10 19:55:16
This wasn't actually true, but yes, now it can onl
|
+ if (job_status_ != STATUS_BROKEN) { |
+ DCHECK_EQ(STATUS_RUNNING, job_status_); |
+ job_status_ = STATUS_FAILED; |
+ // TODO(bnc): Instead of marking alternative service broken, mark |
+ // (origin, alternative service) couple as invalid. |
Ryan Hamilton
2015/04/10 18:37:37
Is this a TODO (instead of being implemented) beca
Bence
2015/04/10 19:55:16
Correct.
|
+ MaybeMarkAlternativeServiceBroken(); |
+ } |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&Job::OnStreamFailedCallback, ptr_factory_.GetWeakPtr(), |
+ ERR_CONNECTION_REFUSED)); |
Ryan Hamilton
2015/04/10 18:37:37
Why ERR_CONNECTION_REFUSED? Actually, this looks a
Bence
2015/04/10 19:55:16
In fact, you are right, this is a lot like the def
Ryan Hamilton
2015/04/11 02:40:41
Is there a difference between the two cases? (defa
Bence
2015/04/13 17:52:40
Only the DCHECK (and the TODO), so I merged them f
|
+ return ERR_IO_PENDING; |
+ |
default: |
if (job_status_ != STATUS_BROKEN) { |
DCHECK_EQ(STATUS_RUNNING, job_status_); |
@@ -804,6 +831,9 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
session_->spdy_session_pool()->FindAvailableSession( |
spdy_session_key, net_log_); |
if (spdy_session && CanUseExistingSpdySession()) { |
+ if (!IsAlternativeCertificateValidForOrigin(spdy_session)) { |
Ryan Hamilton
2015/04/10 18:37:37
We don't need to do this call, unless this job is
Bence
2015/04/10 19:55:16
That is true. I think it might be easier to check
|
+ return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; |
+ } |
// If we're preconnecting, but we already have a SpdySession, we don't |
// actually need to preconnect any sockets, so we're done. |
if (IsPreconnecting()) |
@@ -812,14 +842,14 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { |
next_state_ = STATE_CREATE_STREAM; |
existing_spdy_session_ = spdy_session; |
return OK; |
- } else if (request_ && !request_->HasSpdySessionKey() && using_ssl_) { |
+ } |
+ if (request_ && !request_->HasSpdySessionKey() && using_ssl_) { |
// Update the spdy session key for the request that launched this job. |
request_->SetSpdySessionKey(spdy_session_key); |
} |
// OK, there's no available SPDY session. Let |waiting_job_| resume if it's |
// paused. |
- |
if (waiting_job_) { |
waiting_job_->Resume(this); |
waiting_job_ = NULL; |
@@ -989,6 +1019,9 @@ int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
if (!ssl_started && result < 0 && IsAlternate()) { |
job_status_ = STATUS_BROKEN; |
+ // TODO(bnc): if (result == ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN), then |
+ // instead of marking alternative service broken, mark (origin, alternative |
+ // service) couple as invalid. |
MaybeMarkAlternativeServiceBroken(); |
return result; |
} |
@@ -1131,6 +1164,9 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() { |
spdy_pool->FindAvailableSession(spdy_session_key, net_log_); |
if (spdy_session) { |
+ if (!IsAlternativeCertificateValidForOrigin(spdy_session)) { |
+ return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; |
+ } |
return SetSpdyHttpStream(spdy_session, direct); |
} |
@@ -1146,6 +1182,10 @@ int HttpStreamFactoryImpl::Job::DoCreateStream() { |
return ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY; |
} |
+ if (!IsAlternativeCertificateValidForOrigin(spdy_session)) { |
+ return ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN; |
Ryan Hamilton
2015/04/10 18:37:37
Hm. It seems like there are a lot of different pla
Bence
2015/04/10 19:55:16
I do agree with you. Please let me know if you ha
Ryan Hamilton
2015/04/11 02:40:41
So it looks like each time we get a SPDY session f
Bence
2015/04/13 17:52:40
I've done it, but it doesn't quite feel right. Th
|
+ } |
+ |
new_spdy_session_ = spdy_session; |
spdy_session_direct_ = direct; |
const HostPortPair& host_port_pair = spdy_session_key.host_port_pair(); |