| OLD | NEW | 
|---|
| 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/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" | 
| 6 | 6 | 
| 7 #include "net/base/address_list.h" | 7 #include "net/base/address_list.h" | 
| 8 #include "net/base/host_resolver.h" | 8 #include "net/base/host_resolver.h" | 
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" | 
| 10 #include "net/base/net_log.h" | 10 #include "net/base/net_log.h" | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 60   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 60   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 
| 61   net::ClientSocket* transport = new net::TCPClientSocket( | 61   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 62       addr, &log, net::NetLog::Source()); | 62       addr, &log, net::NetLog::Source()); | 
| 63   int rv = transport->Connect(&callback); | 63   int rv = transport->Connect(&callback); | 
| 64   if (rv == net::ERR_IO_PENDING) | 64   if (rv == net::ERR_IO_PENDING) | 
| 65     rv = callback.WaitForResult(); | 65     rv = callback.WaitForResult(); | 
| 66   EXPECT_EQ(net::OK, rv); | 66   EXPECT_EQ(net::OK, rv); | 
| 67 | 67 | 
| 68   scoped_ptr<net::SSLClientSocket> sock( | 68   scoped_ptr<net::SSLClientSocket> sock( | 
| 69       socket_factory_->CreateSSLClientSocket( | 69       socket_factory_->CreateSSLClientSocket( | 
| 70           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 70           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 71           NULL)); |  | 
| 72 | 71 | 
| 73   EXPECT_FALSE(sock->IsConnected()); | 72   EXPECT_FALSE(sock->IsConnected()); | 
| 74 | 73 | 
| 75   rv = sock->Connect(&callback); | 74   rv = sock->Connect(&callback); | 
| 76   EXPECT_TRUE(net::LogContainsBeginEvent( | 75   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 77       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 76       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 78   if (rv == net::ERR_IO_PENDING) | 77   if (rv == net::ERR_IO_PENDING) | 
| 79     rv = callback.WaitForResult(); | 78     rv = callback.WaitForResult(); | 
| 80   EXPECT_EQ(net::OK, rv); | 79   EXPECT_EQ(net::OK, rv); | 
| 81   EXPECT_TRUE(sock->IsConnected()); | 80   EXPECT_TRUE(sock->IsConnected()); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 98   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 97   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 
| 99   net::ClientSocket* transport = new net::TCPClientSocket( | 98   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 100       addr, &log, net::NetLog::Source()); | 99       addr, &log, net::NetLog::Source()); | 
| 101   int rv = transport->Connect(&callback); | 100   int rv = transport->Connect(&callback); | 
| 102   if (rv == net::ERR_IO_PENDING) | 101   if (rv == net::ERR_IO_PENDING) | 
| 103     rv = callback.WaitForResult(); | 102     rv = callback.WaitForResult(); | 
| 104   EXPECT_EQ(net::OK, rv); | 103   EXPECT_EQ(net::OK, rv); | 
| 105 | 104 | 
| 106   scoped_ptr<net::SSLClientSocket> sock( | 105   scoped_ptr<net::SSLClientSocket> sock( | 
| 107       socket_factory_->CreateSSLClientSocket( | 106       socket_factory_->CreateSSLClientSocket( | 
| 108           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 107           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 109           NULL)); |  | 
| 110 | 108 | 
| 111   EXPECT_FALSE(sock->IsConnected()); | 109   EXPECT_FALSE(sock->IsConnected()); | 
| 112 | 110 | 
| 113   rv = sock->Connect(&callback); | 111   rv = sock->Connect(&callback); | 
| 114   EXPECT_TRUE(net::LogContainsBeginEvent( | 112   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 115       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 113       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 116   if (rv == net::ERR_IO_PENDING) | 114   if (rv == net::ERR_IO_PENDING) | 
| 117     rv = callback.WaitForResult(); | 115     rv = callback.WaitForResult(); | 
| 118 | 116 | 
| 119   EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv); | 117   EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 138   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 136   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 
| 139   net::ClientSocket* transport = new net::TCPClientSocket( | 137   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 140       addr, &log, net::NetLog::Source()); | 138       addr, &log, net::NetLog::Source()); | 
| 141   int rv = transport->Connect(&callback); | 139   int rv = transport->Connect(&callback); | 
| 142   if (rv == net::ERR_IO_PENDING) | 140   if (rv == net::ERR_IO_PENDING) | 
| 143     rv = callback.WaitForResult(); | 141     rv = callback.WaitForResult(); | 
| 144   EXPECT_EQ(net::OK, rv); | 142   EXPECT_EQ(net::OK, rv); | 
| 145 | 143 | 
| 146   scoped_ptr<net::SSLClientSocket> sock( | 144   scoped_ptr<net::SSLClientSocket> sock( | 
| 147       socket_factory_->CreateSSLClientSocket( | 145       socket_factory_->CreateSSLClientSocket( | 
| 148           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 146           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 149           NULL)); |  | 
| 150 | 147 | 
| 151   EXPECT_FALSE(sock->IsConnected()); | 148   EXPECT_FALSE(sock->IsConnected()); | 
| 152 | 149 | 
| 153   rv = sock->Connect(&callback); | 150   rv = sock->Connect(&callback); | 
| 154 | 151 | 
| 155   EXPECT_TRUE(net::LogContainsBeginEvent( | 152   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 156       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 153       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 157   if (rv == net::ERR_IO_PENDING) | 154   if (rv == net::ERR_IO_PENDING) | 
| 158     rv = callback.WaitForResult(); | 155     rv = callback.WaitForResult(); | 
| 159 | 156 | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 182   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 179   net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 
| 183   net::ClientSocket* transport = new net::TCPClientSocket( | 180   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 184       addr, &log, net::NetLog::Source()); | 181       addr, &log, net::NetLog::Source()); | 
| 185   int rv = transport->Connect(&callback); | 182   int rv = transport->Connect(&callback); | 
| 186   if (rv == net::ERR_IO_PENDING) | 183   if (rv == net::ERR_IO_PENDING) | 
| 187     rv = callback.WaitForResult(); | 184     rv = callback.WaitForResult(); | 
| 188   EXPECT_EQ(net::OK, rv); | 185   EXPECT_EQ(net::OK, rv); | 
| 189 | 186 | 
| 190   scoped_ptr<net::SSLClientSocket> sock( | 187   scoped_ptr<net::SSLClientSocket> sock( | 
| 191       socket_factory_->CreateSSLClientSocket( | 188       socket_factory_->CreateSSLClientSocket( | 
| 192           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 189           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 193           NULL)); |  | 
| 194 | 190 | 
| 195   EXPECT_FALSE(sock->IsConnected()); | 191   EXPECT_FALSE(sock->IsConnected()); | 
| 196 | 192 | 
| 197   rv = sock->Connect(&callback); | 193   rv = sock->Connect(&callback); | 
| 198   EXPECT_TRUE(net::LogContainsBeginEvent( | 194   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 199       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 195       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 200   if (rv == net::ERR_IO_PENDING) | 196   if (rv == net::ERR_IO_PENDING) | 
| 201     rv = callback.WaitForResult(); | 197     rv = callback.WaitForResult(); | 
| 202 | 198 | 
| 203   EXPECT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 199   EXPECT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 225   if (rv == net::ERR_IO_PENDING) | 221   if (rv == net::ERR_IO_PENDING) | 
| 226     rv = callback.WaitForResult(); | 222     rv = callback.WaitForResult(); | 
| 227   EXPECT_EQ(net::OK, rv); | 223   EXPECT_EQ(net::OK, rv); | 
| 228 | 224 | 
| 229   net::SSLConfig ssl_config = kDefaultSSLConfig; | 225   net::SSLConfig ssl_config = kDefaultSSLConfig; | 
| 230   ssl_config.send_client_cert = true; | 226   ssl_config.send_client_cert = true; | 
| 231   ssl_config.client_cert = NULL; | 227   ssl_config.client_cert = NULL; | 
| 232 | 228 | 
| 233   scoped_ptr<net::SSLClientSocket> sock( | 229   scoped_ptr<net::SSLClientSocket> sock( | 
| 234       socket_factory_->CreateSSLClientSocket( | 230       socket_factory_->CreateSSLClientSocket( | 
| 235           transport, test_server.host_port_pair().host(), ssl_config, | 231           transport, test_server.host_port_pair(), ssl_config, NULL)); | 
| 236           NULL)); |  | 
| 237 | 232 | 
| 238   EXPECT_FALSE(sock->IsConnected()); | 233   EXPECT_FALSE(sock->IsConnected()); | 
| 239 | 234 | 
| 240   // Our test server accepts certificate-less connections. | 235   // Our test server accepts certificate-less connections. | 
| 241   // TODO(davidben): Add a test which requires them and verify the error. | 236   // TODO(davidben): Add a test which requires them and verify the error. | 
| 242   rv = sock->Connect(&callback); | 237   rv = sock->Connect(&callback); | 
| 243   EXPECT_TRUE(net::LogContainsBeginEvent( | 238   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 244       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 239       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 245   if (rv == net::ERR_IO_PENDING) | 240   if (rv == net::ERR_IO_PENDING) | 
| 246     rv = callback.WaitForResult(); | 241     rv = callback.WaitForResult(); | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 268   TestCompletionCallback callback; | 263   TestCompletionCallback callback; | 
| 269   net::ClientSocket* transport = new net::TCPClientSocket( | 264   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 270       addr, NULL, net::NetLog::Source()); | 265       addr, NULL, net::NetLog::Source()); | 
| 271   int rv = transport->Connect(&callback); | 266   int rv = transport->Connect(&callback); | 
| 272   if (rv == net::ERR_IO_PENDING) | 267   if (rv == net::ERR_IO_PENDING) | 
| 273     rv = callback.WaitForResult(); | 268     rv = callback.WaitForResult(); | 
| 274   EXPECT_EQ(net::OK, rv); | 269   EXPECT_EQ(net::OK, rv); | 
| 275 | 270 | 
| 276   scoped_ptr<net::SSLClientSocket> sock( | 271   scoped_ptr<net::SSLClientSocket> sock( | 
| 277       socket_factory_->CreateSSLClientSocket( | 272       socket_factory_->CreateSSLClientSocket( | 
| 278           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 273           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 279           NULL)); |  | 
| 280 | 274 | 
| 281   rv = sock->Connect(&callback); | 275   rv = sock->Connect(&callback); | 
| 282   if (rv == net::ERR_IO_PENDING) | 276   if (rv == net::ERR_IO_PENDING) | 
| 283     rv = callback.WaitForResult(); | 277     rv = callback.WaitForResult(); | 
| 284   EXPECT_EQ(net::OK, rv); | 278   EXPECT_EQ(net::OK, rv); | 
| 285   EXPECT_TRUE(sock->IsConnected()); | 279   EXPECT_TRUE(sock->IsConnected()); | 
| 286 | 280 | 
| 287   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 281   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 
| 288   scoped_refptr<net::IOBuffer> request_buffer( | 282   scoped_refptr<net::IOBuffer> request_buffer( | 
| 289       new net::IOBuffer(arraysize(request_text) - 1)); | 283       new net::IOBuffer(arraysize(request_text) - 1)); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 324 | 318 | 
| 325   net::ClientSocket* transport = new net::TCPClientSocket( | 319   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 326       addr, NULL, net::NetLog::Source()); | 320       addr, NULL, net::NetLog::Source()); | 
| 327   int rv = transport->Connect(&callback); | 321   int rv = transport->Connect(&callback); | 
| 328   if (rv == net::ERR_IO_PENDING) | 322   if (rv == net::ERR_IO_PENDING) | 
| 329     rv = callback.WaitForResult(); | 323     rv = callback.WaitForResult(); | 
| 330   EXPECT_EQ(net::OK, rv); | 324   EXPECT_EQ(net::OK, rv); | 
| 331 | 325 | 
| 332   scoped_ptr<net::SSLClientSocket> sock( | 326   scoped_ptr<net::SSLClientSocket> sock( | 
| 333       socket_factory_->CreateSSLClientSocket( | 327       socket_factory_->CreateSSLClientSocket( | 
| 334           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 328           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 335           NULL)); |  | 
| 336 | 329 | 
| 337   rv = sock->Connect(&callback); | 330   rv = sock->Connect(&callback); | 
| 338   if (rv == net::ERR_IO_PENDING) | 331   if (rv == net::ERR_IO_PENDING) | 
| 339     rv = callback.WaitForResult(); | 332     rv = callback.WaitForResult(); | 
| 340   EXPECT_EQ(net::OK, rv); | 333   EXPECT_EQ(net::OK, rv); | 
| 341   EXPECT_TRUE(sock->IsConnected()); | 334   EXPECT_TRUE(sock->IsConnected()); | 
| 342 | 335 | 
| 343   // Issue a "hanging" Read first. | 336   // Issue a "hanging" Read first. | 
| 344   scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); | 337   scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); | 
| 345   rv = sock->Read(buf, 4096, &callback); | 338   rv = sock->Read(buf, 4096, &callback); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 379   TestCompletionCallback callback; | 372   TestCompletionCallback callback; | 
| 380   net::ClientSocket* transport = new net::TCPClientSocket( | 373   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 381       addr, NULL, net::NetLog::Source()); | 374       addr, NULL, net::NetLog::Source()); | 
| 382   int rv = transport->Connect(&callback); | 375   int rv = transport->Connect(&callback); | 
| 383   if (rv == net::ERR_IO_PENDING) | 376   if (rv == net::ERR_IO_PENDING) | 
| 384     rv = callback.WaitForResult(); | 377     rv = callback.WaitForResult(); | 
| 385   EXPECT_EQ(net::OK, rv); | 378   EXPECT_EQ(net::OK, rv); | 
| 386 | 379 | 
| 387   scoped_ptr<net::SSLClientSocket> sock( | 380   scoped_ptr<net::SSLClientSocket> sock( | 
| 388       socket_factory_->CreateSSLClientSocket( | 381       socket_factory_->CreateSSLClientSocket( | 
| 389           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 382           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 390           NULL)); |  | 
| 391 | 383 | 
| 392   rv = sock->Connect(&callback); | 384   rv = sock->Connect(&callback); | 
| 393   if (rv == net::ERR_IO_PENDING) | 385   if (rv == net::ERR_IO_PENDING) | 
| 394     rv = callback.WaitForResult(); | 386     rv = callback.WaitForResult(); | 
| 395   EXPECT_EQ(net::OK, rv); | 387   EXPECT_EQ(net::OK, rv); | 
| 396 | 388 | 
| 397   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 389   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 
| 398   scoped_refptr<net::IOBuffer> request_buffer( | 390   scoped_refptr<net::IOBuffer> request_buffer( | 
| 399       new net::IOBuffer(arraysize(request_text) - 1)); | 391       new net::IOBuffer(arraysize(request_text) - 1)); | 
| 400   memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 392   memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 430   TestCompletionCallback callback; | 422   TestCompletionCallback callback; | 
| 431   net::ClientSocket* transport = new net::TCPClientSocket( | 423   net::ClientSocket* transport = new net::TCPClientSocket( | 
| 432       addr, NULL, net::NetLog::Source()); | 424       addr, NULL, net::NetLog::Source()); | 
| 433   int rv = transport->Connect(&callback); | 425   int rv = transport->Connect(&callback); | 
| 434   if (rv == net::ERR_IO_PENDING) | 426   if (rv == net::ERR_IO_PENDING) | 
| 435     rv = callback.WaitForResult(); | 427     rv = callback.WaitForResult(); | 
| 436   EXPECT_EQ(net::OK, rv); | 428   EXPECT_EQ(net::OK, rv); | 
| 437 | 429 | 
| 438   scoped_ptr<net::SSLClientSocket> sock( | 430   scoped_ptr<net::SSLClientSocket> sock( | 
| 439       socket_factory_->CreateSSLClientSocket( | 431       socket_factory_->CreateSSLClientSocket( | 
| 440           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 432           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 441           NULL)); |  | 
| 442 | 433 | 
| 443   rv = sock->Connect(&callback); | 434   rv = sock->Connect(&callback); | 
| 444   if (rv == net::ERR_IO_PENDING) | 435   if (rv == net::ERR_IO_PENDING) | 
| 445     rv = callback.WaitForResult(); | 436     rv = callback.WaitForResult(); | 
| 446   EXPECT_EQ(net::OK, rv); | 437   EXPECT_EQ(net::OK, rv); | 
| 447 | 438 | 
| 448   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 439   const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 
| 449   scoped_refptr<net::IOBuffer> request_buffer( | 440   scoped_refptr<net::IOBuffer> request_buffer( | 
| 450       new net::IOBuffer(arraysize(request_text) - 1)); | 441       new net::IOBuffer(arraysize(request_text) - 1)); | 
| 451   memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 442   memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 501 | 492 | 
| 502   net::ClientSocket* transport = | 493   net::ClientSocket* transport = | 
| 503       new net::MockTCPClientSocket(addr, NULL, &data); | 494       new net::MockTCPClientSocket(addr, NULL, &data); | 
| 504   int rv = transport->Connect(&callback); | 495   int rv = transport->Connect(&callback); | 
| 505   if (rv == net::ERR_IO_PENDING) | 496   if (rv == net::ERR_IO_PENDING) | 
| 506     rv = callback.WaitForResult(); | 497     rv = callback.WaitForResult(); | 
| 507   EXPECT_EQ(net::OK, rv); | 498   EXPECT_EQ(net::OK, rv); | 
| 508 | 499 | 
| 509   scoped_ptr<net::SSLClientSocket> sock( | 500   scoped_ptr<net::SSLClientSocket> sock( | 
| 510       socket_factory_->CreateSSLClientSocket( | 501       socket_factory_->CreateSSLClientSocket( | 
| 511           transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 502           transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 
| 512           NULL)); |  | 
| 513 | 503 | 
| 514   rv = sock->Connect(&callback); | 504   rv = sock->Connect(&callback); | 
| 515   EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); | 505   EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); | 
| 516 } | 506 } | 
| 517 | 507 | 
| 518 #if defined(USE_OPENSSL) | 508 #if defined(USE_OPENSSL) | 
| 519 // TODO(rsleevi): Not implemented for Schannel or OpenSSL. Schannel is | 509 // TODO(rsleevi): Not implemented for Schannel or OpenSSL. Schannel is | 
| 520 // controlled by the SSL client socket factory, rather than a define, so it | 510 // controlled by the SSL client socket factory, rather than a define, so it | 
| 521 // cannot be conditionally disabled here. As Schannel is only used when | 511 // cannot be conditionally disabled here. As Schannel is only used when | 
| 522 // performing client authentication, it will not be tested here. | 512 // performing client authentication, it will not be tested here. | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 551   if (rv == net::ERR_IO_PENDING) | 541   if (rv == net::ERR_IO_PENDING) | 
| 552     rv = callback.WaitForResult(); | 542     rv = callback.WaitForResult(); | 
| 553   EXPECT_EQ(net::OK, rv); | 543   EXPECT_EQ(net::OK, rv); | 
| 554 | 544 | 
| 555   net::SSLConfig ssl_config; | 545   net::SSLConfig ssl_config; | 
| 556   for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 546   for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 
| 557     ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 547     ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 
| 558 | 548 | 
| 559   scoped_ptr<net::SSLClientSocket> sock( | 549   scoped_ptr<net::SSLClientSocket> sock( | 
| 560       socket_factory_->CreateSSLClientSocket( | 550       socket_factory_->CreateSSLClientSocket( | 
| 561           transport, test_server.host_port_pair().host(), | 551           transport, test_server.host_port_pair(), ssl_config, NULL)); | 
| 562           ssl_config, NULL)); |  | 
| 563 | 552 | 
| 564   EXPECT_FALSE(sock->IsConnected()); | 553   EXPECT_FALSE(sock->IsConnected()); | 
| 565 | 554 | 
| 566   rv = sock->Connect(&callback); | 555   rv = sock->Connect(&callback); | 
| 567   EXPECT_TRUE(net::LogContainsBeginEvent( | 556   EXPECT_TRUE(net::LogContainsBeginEvent( | 
| 568       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 557       log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 
| 569 | 558 | 
| 570   // NSS has special handling that maps a handshake_failure alert received | 559   // NSS has special handling that maps a handshake_failure alert received | 
| 571   // immediately after a client_hello to be a mismatched cipher suite error, | 560   // immediately after a client_hello to be a mismatched cipher suite error, | 
| 572   // leading to ERR_SSL_VERSION_OR_CIPHER_MISMATCH. When using OpenSSL or | 561   // leading to ERR_SSL_VERSION_OR_CIPHER_MISMATCH. When using OpenSSL or | 
| 573   // Secure Transport (OS X), the handshake_failure is bubbled up without any | 562   // Secure Transport (OS X), the handshake_failure is bubbled up without any | 
| 574   // interpretation, leading to ERR_SSL_PROTOCOL_ERROR. Either way, a failure | 563   // interpretation, leading to ERR_SSL_PROTOCOL_ERROR. Either way, a failure | 
| 575   // indicates that no cipher suite was negotiated with the test server. | 564   // indicates that no cipher suite was negotiated with the test server. | 
| 576   if (rv == net::ERR_IO_PENDING) | 565   if (rv == net::ERR_IO_PENDING) | 
| 577     rv = callback.WaitForResult(); | 566     rv = callback.WaitForResult(); | 
| 578   EXPECT_TRUE(rv == net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH || | 567   EXPECT_TRUE(rv == net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH || | 
| 579               rv == net::ERR_SSL_PROTOCOL_ERROR); | 568               rv == net::ERR_SSL_PROTOCOL_ERROR); | 
| 580   // The exact ordering differs between SSLClientSocketNSS (which issues an | 569   // The exact ordering differs between SSLClientSocketNSS (which issues an | 
| 581   // extra read) and SSLClientSocketMac (which does not). Just make sure the | 570   // extra read) and SSLClientSocketMac (which does not). Just make sure the | 
| 582   // error appears somewhere in the log. | 571   // error appears somewhere in the log. | 
| 583   net::ExpectLogContainsSomewhere(log.entries(), 0, | 572   net::ExpectLogContainsSomewhere(log.entries(), 0, | 
| 584                                   net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 573                                   net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 
| 585                                   net::NetLog::PHASE_NONE); | 574                                   net::NetLog::PHASE_NONE); | 
| 586 | 575 | 
| 587   // We cannot test sock->IsConnected(), as the NSS implementation disconnects | 576   // We cannot test sock->IsConnected(), as the NSS implementation disconnects | 
| 588   // the socket when it encounters an error, whereas other implementations | 577   // the socket when it encounters an error, whereas other implementations | 
| 589   // leave it connected. | 578   // leave it connected. | 
| 590   EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); | 579   EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); | 
| 591 } | 580 } | 
| OLD | NEW | 
|---|