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

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

Issue 6120002: Disable False Start and clear the SSL client auth cache for HTTPS proxies on failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: restructure test/comments to match the non-proxy Created 9 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
« no previous file with comments | « no previous file | net/http/http_stream_request.cc » ('j') | net/http/http_stream_request.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 8389 matching lines...) Expand 10 before | Expand all | Expand 10 after
8400 // checked against what ssl_data3 should return. 8400 // checked against what ssl_data3 should return.
8401 rv = callback.WaitForResult(); 8401 rv = callback.WaitForResult();
8402 ASSERT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); 8402 ASSERT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv);
8403 8403
8404 // Ensure that the client certificate is removed from the cache on a 8404 // Ensure that the client certificate is removed from the cache on a
8405 // handshake failure. 8405 // handshake failure.
8406 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", 8406 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443",
8407 &client_cert)); 8407 &client_cert));
8408 } 8408 }
8409 8409
8410 // Ensure that a client certificate is removed from the SSL client auth
8411 // cache when:
8412 // 1) An HTTPS proxy is involved.
8413 // 3) The HTTPS proxy requests a client certificate.
8414 // 4) The client supplies an invalid/unacceptable certificate for the
8415 // proxy.
8416 // The test is repeated twice, first for connecting to an HTTPS endpoint,
8417 // then for connecting to an HTTP endpoint.
8418 TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) {
8419 SessionDependencies session_deps(
8420 ProxyService::CreateFixed("https://proxy:70"));
8421 CapturingBoundNetLog log(CapturingNetLog::kUnbounded);
8422 session_deps.net_log = log.bound().net_log();
8423
8424 scoped_refptr<SSLCertRequestInfo> cert_request(new SSLCertRequestInfo());
8425 cert_request->host_and_port = "proxy:70";
8426
8427 // See ClientAuthCertCache_Direct_NoFalseStart for the explanation of
8428 // [ssl_]data[1-3]. Rather than represending the endpoint
8429 // (www.example.com:443), they represent failures with the HTTPS proxy
8430 // (proxy:70).
8431 SSLSocketDataProvider ssl_data1(true /* async */,
8432 net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
8433 ssl_data1.cert_request_info = cert_request.get();
8434 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data1);
8435 net::StaticSocketDataProvider data1(NULL, 0, NULL, 0);
8436 session_deps.socket_factory.AddSocketDataProvider(&data1);
8437
8438 SSLSocketDataProvider ssl_data2(true /* async */,
8439 net::ERR_SSL_PROTOCOL_ERROR);
8440 ssl_data2.cert_request_info = cert_request.get();
8441 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data2);
8442 net::StaticSocketDataProvider data2(NULL, 0, NULL, 0);
8443 session_deps.socket_factory.AddSocketDataProvider(&data2);
8444
8445 SSLSocketDataProvider ssl_data3(true /* async */,
8446 net::ERR_SSL_PROTOCOL_ERROR);
8447 ssl_data3.cert_request_info = cert_request.get();
8448 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl_data3);
8449 net::StaticSocketDataProvider data3(NULL, 0, NULL, 0);
8450 session_deps.socket_factory.AddSocketDataProvider(&data3);
8451
8452 net::HttpRequestInfo requests[2];
8453 requests[0].url = GURL("https://www.example.com/");
8454 requests[0].method = "GET";
8455 requests[0].load_flags = net::LOAD_NORMAL;
8456
8457 requests[1].url = GURL("http://www.example.com/");
8458 requests[1].method = "GET";
8459 requests[1].load_flags = net::LOAD_NORMAL;
8460
8461 for (size_t i = 0; i < arraysize(requests); ++i) {
8462 session_deps.socket_factory.ResetNextMockIndexes();
8463 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps));
8464 scoped_ptr<HttpNetworkTransaction> trans(
8465 new HttpNetworkTransaction(session));
8466
8467 // Begin the SSL handshake with the proxy.
8468 TestCompletionCallback callback;
8469 int rv = trans->Start(&requests[i], &callback, net::BoundNetLog());
8470 ASSERT_EQ(net::ERR_IO_PENDING, rv);
8471
8472 // Complete the SSL handshake, which should abort due to requiring a
8473 // client certificate.
8474 rv = callback.WaitForResult();
8475 ASSERT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv);
8476
8477 // Indicate that no certificate should be supplied. From the perspective
8478 // of SSLClientCertCache, NULL is just as meaningful as a real
8479 // certificate, so this is the same as supply a
8480 // legitimate-but-unacceptable certificate.
8481 rv = trans->RestartWithCertificate(NULL, &callback);
8482 ASSERT_EQ(net::ERR_IO_PENDING, rv);
8483
8484 // Ensure the certificate was added to the client auth cache before
8485 // allowing the connection to continue restarting.
8486 scoped_refptr<X509Certificate> client_cert;
8487 ASSERT_TRUE(session->ssl_client_auth_cache()->Lookup("proxy:70",
8488 &client_cert));
8489 ASSERT_EQ(NULL, client_cert.get());
8490 // Ensure the certificate was NOT cached for the endpoint. This only
8491 // applies to HTTPS requests, but is fine to check for HTTP requests.
8492 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443",
8493 &client_cert));
8494
8495 // Restart the handshake. This will consume ssl_data2, which fails, and
8496 // then consume ssl_data3, which should also fail. The result code is
8497 // checked against what ssl_data3 should return.
8498 rv = callback.WaitForResult();
8499 ASSERT_EQ(net::ERR_PROXY_CONNECTION_FAILED, rv);
8500
8501 // Now that the new handshake has failed, ensure that the client
8502 // certificate was removed from the client auth cache.
8503 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70",
8504 &client_cert));
8505 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443",
8506 &client_cert));
8507 }
8508 }
8509
8410 } // namespace net 8510 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_stream_request.cc » ('j') | net/http/http_stream_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698