| 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().host(), |
| 71 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 71 NULL)); | 72 NULL)); |
| 72 | 73 |
| 73 EXPECT_FALSE(sock->IsConnected()); | 74 EXPECT_FALSE(sock->IsConnected()); |
| 74 | 75 |
| 75 rv = sock->Connect(&callback); | 76 rv = sock->Connect(&callback); |
| 76 EXPECT_TRUE(net::LogContainsBeginEvent( | 77 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 77 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 78 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 78 if (rv == net::ERR_IO_PENDING) | 79 if (rv == net::ERR_IO_PENDING) |
| 79 rv = callback.WaitForResult(); | 80 rv = callback.WaitForResult(); |
| 80 EXPECT_EQ(net::OK, rv); | 81 EXPECT_EQ(net::OK, rv); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 99 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
| 99 net::ClientSocket* transport = new net::TCPClientSocket( | 100 net::ClientSocket* transport = new net::TCPClientSocket( |
| 100 addr, &log, net::NetLog::Source()); | 101 addr, &log, net::NetLog::Source()); |
| 101 int rv = transport->Connect(&callback); | 102 int rv = transport->Connect(&callback); |
| 102 if (rv == net::ERR_IO_PENDING) | 103 if (rv == net::ERR_IO_PENDING) |
| 103 rv = callback.WaitForResult(); | 104 rv = callback.WaitForResult(); |
| 104 EXPECT_EQ(net::OK, rv); | 105 EXPECT_EQ(net::OK, rv); |
| 105 | 106 |
| 106 scoped_ptr<net::SSLClientSocket> sock( | 107 scoped_ptr<net::SSLClientSocket> sock( |
| 107 socket_factory_->CreateSSLClientSocket( | 108 socket_factory_->CreateSSLClientSocket( |
| 108 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 109 transport, test_server.host_port_pair().host(), |
| 110 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 109 NULL)); | 111 NULL)); |
| 110 | 112 |
| 111 EXPECT_FALSE(sock->IsConnected()); | 113 EXPECT_FALSE(sock->IsConnected()); |
| 112 | 114 |
| 113 rv = sock->Connect(&callback); | 115 rv = sock->Connect(&callback); |
| 114 EXPECT_TRUE(net::LogContainsBeginEvent( | 116 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 115 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 117 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 116 if (rv == net::ERR_IO_PENDING) | 118 if (rv == net::ERR_IO_PENDING) |
| 117 rv = callback.WaitForResult(); | 119 rv = callback.WaitForResult(); |
| 118 | 120 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 138 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 140 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
| 139 net::ClientSocket* transport = new net::TCPClientSocket( | 141 net::ClientSocket* transport = new net::TCPClientSocket( |
| 140 addr, &log, net::NetLog::Source()); | 142 addr, &log, net::NetLog::Source()); |
| 141 int rv = transport->Connect(&callback); | 143 int rv = transport->Connect(&callback); |
| 142 if (rv == net::ERR_IO_PENDING) | 144 if (rv == net::ERR_IO_PENDING) |
| 143 rv = callback.WaitForResult(); | 145 rv = callback.WaitForResult(); |
| 144 EXPECT_EQ(net::OK, rv); | 146 EXPECT_EQ(net::OK, rv); |
| 145 | 147 |
| 146 scoped_ptr<net::SSLClientSocket> sock( | 148 scoped_ptr<net::SSLClientSocket> sock( |
| 147 socket_factory_->CreateSSLClientSocket( | 149 socket_factory_->CreateSSLClientSocket( |
| 148 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 150 transport, test_server.host_port_pair().host(), |
| 151 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 149 NULL)); | 152 NULL)); |
| 150 | 153 |
| 151 EXPECT_FALSE(sock->IsConnected()); | 154 EXPECT_FALSE(sock->IsConnected()); |
| 152 | 155 |
| 153 rv = sock->Connect(&callback); | 156 rv = sock->Connect(&callback); |
| 154 | 157 |
| 155 EXPECT_TRUE(net::LogContainsBeginEvent( | 158 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 156 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 159 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 157 if (rv == net::ERR_IO_PENDING) | 160 if (rv == net::ERR_IO_PENDING) |
| 158 rv = callback.WaitForResult(); | 161 rv = callback.WaitForResult(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 182 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 185 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
| 183 net::ClientSocket* transport = new net::TCPClientSocket( | 186 net::ClientSocket* transport = new net::TCPClientSocket( |
| 184 addr, &log, net::NetLog::Source()); | 187 addr, &log, net::NetLog::Source()); |
| 185 int rv = transport->Connect(&callback); | 188 int rv = transport->Connect(&callback); |
| 186 if (rv == net::ERR_IO_PENDING) | 189 if (rv == net::ERR_IO_PENDING) |
| 187 rv = callback.WaitForResult(); | 190 rv = callback.WaitForResult(); |
| 188 EXPECT_EQ(net::OK, rv); | 191 EXPECT_EQ(net::OK, rv); |
| 189 | 192 |
| 190 scoped_ptr<net::SSLClientSocket> sock( | 193 scoped_ptr<net::SSLClientSocket> sock( |
| 191 socket_factory_->CreateSSLClientSocket( | 194 socket_factory_->CreateSSLClientSocket( |
| 192 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 195 transport, test_server.host_port_pair().host(), |
| 196 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 193 NULL)); | 197 NULL)); |
| 194 | 198 |
| 195 EXPECT_FALSE(sock->IsConnected()); | 199 EXPECT_FALSE(sock->IsConnected()); |
| 196 | 200 |
| 197 rv = sock->Connect(&callback); | 201 rv = sock->Connect(&callback); |
| 198 EXPECT_TRUE(net::LogContainsBeginEvent( | 202 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 199 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 203 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 200 if (rv == net::ERR_IO_PENDING) | 204 if (rv == net::ERR_IO_PENDING) |
| 201 rv = callback.WaitForResult(); | 205 rv = callback.WaitForResult(); |
| 202 | 206 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 225 if (rv == net::ERR_IO_PENDING) | 229 if (rv == net::ERR_IO_PENDING) |
| 226 rv = callback.WaitForResult(); | 230 rv = callback.WaitForResult(); |
| 227 EXPECT_EQ(net::OK, rv); | 231 EXPECT_EQ(net::OK, rv); |
| 228 | 232 |
| 229 net::SSLConfig ssl_config = kDefaultSSLConfig; | 233 net::SSLConfig ssl_config = kDefaultSSLConfig; |
| 230 ssl_config.send_client_cert = true; | 234 ssl_config.send_client_cert = true; |
| 231 ssl_config.client_cert = NULL; | 235 ssl_config.client_cert = NULL; |
| 232 | 236 |
| 233 scoped_ptr<net::SSLClientSocket> sock( | 237 scoped_ptr<net::SSLClientSocket> sock( |
| 234 socket_factory_->CreateSSLClientSocket( | 238 socket_factory_->CreateSSLClientSocket( |
| 235 transport, test_server.host_port_pair().host(), ssl_config, | 239 transport, test_server.host_port_pair().host(), |
| 240 test_server.host_port_pair().port(), ssl_config, |
| 236 NULL)); | 241 NULL)); |
| 237 | 242 |
| 238 EXPECT_FALSE(sock->IsConnected()); | 243 EXPECT_FALSE(sock->IsConnected()); |
| 239 | 244 |
| 240 // Our test server accepts certificate-less connections. | 245 // Our test server accepts certificate-less connections. |
| 241 // TODO(davidben): Add a test which requires them and verify the error. | 246 // TODO(davidben): Add a test which requires them and verify the error. |
| 242 rv = sock->Connect(&callback); | 247 rv = sock->Connect(&callback); |
| 243 EXPECT_TRUE(net::LogContainsBeginEvent( | 248 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 244 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 249 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 245 if (rv == net::ERR_IO_PENDING) | 250 if (rv == net::ERR_IO_PENDING) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 268 TestCompletionCallback callback; | 273 TestCompletionCallback callback; |
| 269 net::ClientSocket* transport = new net::TCPClientSocket( | 274 net::ClientSocket* transport = new net::TCPClientSocket( |
| 270 addr, NULL, net::NetLog::Source()); | 275 addr, NULL, net::NetLog::Source()); |
| 271 int rv = transport->Connect(&callback); | 276 int rv = transport->Connect(&callback); |
| 272 if (rv == net::ERR_IO_PENDING) | 277 if (rv == net::ERR_IO_PENDING) |
| 273 rv = callback.WaitForResult(); | 278 rv = callback.WaitForResult(); |
| 274 EXPECT_EQ(net::OK, rv); | 279 EXPECT_EQ(net::OK, rv); |
| 275 | 280 |
| 276 scoped_ptr<net::SSLClientSocket> sock( | 281 scoped_ptr<net::SSLClientSocket> sock( |
| 277 socket_factory_->CreateSSLClientSocket( | 282 socket_factory_->CreateSSLClientSocket( |
| 278 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 283 transport, test_server.host_port_pair().host(), |
| 284 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 279 NULL)); | 285 NULL)); |
| 280 | 286 |
| 281 rv = sock->Connect(&callback); | 287 rv = sock->Connect(&callback); |
| 282 if (rv == net::ERR_IO_PENDING) | 288 if (rv == net::ERR_IO_PENDING) |
| 283 rv = callback.WaitForResult(); | 289 rv = callback.WaitForResult(); |
| 284 EXPECT_EQ(net::OK, rv); | 290 EXPECT_EQ(net::OK, rv); |
| 285 EXPECT_TRUE(sock->IsConnected()); | 291 EXPECT_TRUE(sock->IsConnected()); |
| 286 | 292 |
| 287 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 293 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
| 288 scoped_refptr<net::IOBuffer> request_buffer( | 294 scoped_refptr<net::IOBuffer> request_buffer( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 330 |
| 325 net::ClientSocket* transport = new net::TCPClientSocket( | 331 net::ClientSocket* transport = new net::TCPClientSocket( |
| 326 addr, NULL, net::NetLog::Source()); | 332 addr, NULL, net::NetLog::Source()); |
| 327 int rv = transport->Connect(&callback); | 333 int rv = transport->Connect(&callback); |
| 328 if (rv == net::ERR_IO_PENDING) | 334 if (rv == net::ERR_IO_PENDING) |
| 329 rv = callback.WaitForResult(); | 335 rv = callback.WaitForResult(); |
| 330 EXPECT_EQ(net::OK, rv); | 336 EXPECT_EQ(net::OK, rv); |
| 331 | 337 |
| 332 scoped_ptr<net::SSLClientSocket> sock( | 338 scoped_ptr<net::SSLClientSocket> sock( |
| 333 socket_factory_->CreateSSLClientSocket( | 339 socket_factory_->CreateSSLClientSocket( |
| 334 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 340 transport, test_server.host_port_pair().host(), |
| 341 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 335 NULL)); | 342 NULL)); |
| 336 | 343 |
| 337 rv = sock->Connect(&callback); | 344 rv = sock->Connect(&callback); |
| 338 if (rv == net::ERR_IO_PENDING) | 345 if (rv == net::ERR_IO_PENDING) |
| 339 rv = callback.WaitForResult(); | 346 rv = callback.WaitForResult(); |
| 340 EXPECT_EQ(net::OK, rv); | 347 EXPECT_EQ(net::OK, rv); |
| 341 EXPECT_TRUE(sock->IsConnected()); | 348 EXPECT_TRUE(sock->IsConnected()); |
| 342 | 349 |
| 343 // Issue a "hanging" Read first. | 350 // Issue a "hanging" Read first. |
| 344 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); | 351 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 TestCompletionCallback callback; | 386 TestCompletionCallback callback; |
| 380 net::ClientSocket* transport = new net::TCPClientSocket( | 387 net::ClientSocket* transport = new net::TCPClientSocket( |
| 381 addr, NULL, net::NetLog::Source()); | 388 addr, NULL, net::NetLog::Source()); |
| 382 int rv = transport->Connect(&callback); | 389 int rv = transport->Connect(&callback); |
| 383 if (rv == net::ERR_IO_PENDING) | 390 if (rv == net::ERR_IO_PENDING) |
| 384 rv = callback.WaitForResult(); | 391 rv = callback.WaitForResult(); |
| 385 EXPECT_EQ(net::OK, rv); | 392 EXPECT_EQ(net::OK, rv); |
| 386 | 393 |
| 387 scoped_ptr<net::SSLClientSocket> sock( | 394 scoped_ptr<net::SSLClientSocket> sock( |
| 388 socket_factory_->CreateSSLClientSocket( | 395 socket_factory_->CreateSSLClientSocket( |
| 389 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 396 transport, test_server.host_port_pair().host(), |
| 397 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 390 NULL)); | 398 NULL)); |
| 391 | 399 |
| 392 rv = sock->Connect(&callback); | 400 rv = sock->Connect(&callback); |
| 393 if (rv == net::ERR_IO_PENDING) | 401 if (rv == net::ERR_IO_PENDING) |
| 394 rv = callback.WaitForResult(); | 402 rv = callback.WaitForResult(); |
| 395 EXPECT_EQ(net::OK, rv); | 403 EXPECT_EQ(net::OK, rv); |
| 396 | 404 |
| 397 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 405 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
| 398 scoped_refptr<net::IOBuffer> request_buffer( | 406 scoped_refptr<net::IOBuffer> request_buffer( |
| 399 new net::IOBuffer(arraysize(request_text) - 1)); | 407 new net::IOBuffer(arraysize(request_text) - 1)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 430 TestCompletionCallback callback; | 438 TestCompletionCallback callback; |
| 431 net::ClientSocket* transport = new net::TCPClientSocket( | 439 net::ClientSocket* transport = new net::TCPClientSocket( |
| 432 addr, NULL, net::NetLog::Source()); | 440 addr, NULL, net::NetLog::Source()); |
| 433 int rv = transport->Connect(&callback); | 441 int rv = transport->Connect(&callback); |
| 434 if (rv == net::ERR_IO_PENDING) | 442 if (rv == net::ERR_IO_PENDING) |
| 435 rv = callback.WaitForResult(); | 443 rv = callback.WaitForResult(); |
| 436 EXPECT_EQ(net::OK, rv); | 444 EXPECT_EQ(net::OK, rv); |
| 437 | 445 |
| 438 scoped_ptr<net::SSLClientSocket> sock( | 446 scoped_ptr<net::SSLClientSocket> sock( |
| 439 socket_factory_->CreateSSLClientSocket( | 447 socket_factory_->CreateSSLClientSocket( |
| 440 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 448 transport, test_server.host_port_pair().host(), |
| 449 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 441 NULL)); | 450 NULL)); |
| 442 | 451 |
| 443 rv = sock->Connect(&callback); | 452 rv = sock->Connect(&callback); |
| 444 if (rv == net::ERR_IO_PENDING) | 453 if (rv == net::ERR_IO_PENDING) |
| 445 rv = callback.WaitForResult(); | 454 rv = callback.WaitForResult(); |
| 446 EXPECT_EQ(net::OK, rv); | 455 EXPECT_EQ(net::OK, rv); |
| 447 | 456 |
| 448 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 457 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
| 449 scoped_refptr<net::IOBuffer> request_buffer( | 458 scoped_refptr<net::IOBuffer> request_buffer( |
| 450 new net::IOBuffer(arraysize(request_text) - 1)); | 459 new net::IOBuffer(arraysize(request_text) - 1)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 510 |
| 502 net::ClientSocket* transport = | 511 net::ClientSocket* transport = |
| 503 new net::MockTCPClientSocket(addr, NULL, &data); | 512 new net::MockTCPClientSocket(addr, NULL, &data); |
| 504 int rv = transport->Connect(&callback); | 513 int rv = transport->Connect(&callback); |
| 505 if (rv == net::ERR_IO_PENDING) | 514 if (rv == net::ERR_IO_PENDING) |
| 506 rv = callback.WaitForResult(); | 515 rv = callback.WaitForResult(); |
| 507 EXPECT_EQ(net::OK, rv); | 516 EXPECT_EQ(net::OK, rv); |
| 508 | 517 |
| 509 scoped_ptr<net::SSLClientSocket> sock( | 518 scoped_ptr<net::SSLClientSocket> sock( |
| 510 socket_factory_->CreateSSLClientSocket( | 519 socket_factory_->CreateSSLClientSocket( |
| 511 transport, test_server.host_port_pair().host(), kDefaultSSLConfig, | 520 transport, test_server.host_port_pair().host(), |
| 521 test_server.host_port_pair().port(), kDefaultSSLConfig, |
| 512 NULL)); | 522 NULL)); |
| 513 | 523 |
| 514 rv = sock->Connect(&callback); | 524 rv = sock->Connect(&callback); |
| 515 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); | 525 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); |
| 516 } | 526 } |
| 517 | 527 |
| 518 #if defined(USE_OPENSSL) | 528 #if defined(USE_OPENSSL) |
| 519 // TODO(rsleevi): Not implemented for Schannel or OpenSSL. Schannel is | 529 // TODO(rsleevi): Not implemented for Schannel or OpenSSL. Schannel is |
| 520 // controlled by the SSL client socket factory, rather than a define, so it | 530 // 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 | 531 // cannot be conditionally disabled here. As Schannel is only used when |
| (...skipping 30 matching lines...) Expand all Loading... |
| 552 rv = callback.WaitForResult(); | 562 rv = callback.WaitForResult(); |
| 553 EXPECT_EQ(net::OK, rv); | 563 EXPECT_EQ(net::OK, rv); |
| 554 | 564 |
| 555 net::SSLConfig ssl_config; | 565 net::SSLConfig ssl_config; |
| 556 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 566 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) |
| 557 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 567 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); |
| 558 | 568 |
| 559 scoped_ptr<net::SSLClientSocket> sock( | 569 scoped_ptr<net::SSLClientSocket> sock( |
| 560 socket_factory_->CreateSSLClientSocket( | 570 socket_factory_->CreateSSLClientSocket( |
| 561 transport, test_server.host_port_pair().host(), | 571 transport, test_server.host_port_pair().host(), |
| 562 ssl_config, NULL)); | 572 test_server.host_port_pair().port(), ssl_config, NULL)); |
| 563 | 573 |
| 564 EXPECT_FALSE(sock->IsConnected()); | 574 EXPECT_FALSE(sock->IsConnected()); |
| 565 | 575 |
| 566 rv = sock->Connect(&callback); | 576 rv = sock->Connect(&callback); |
| 567 EXPECT_TRUE(net::LogContainsBeginEvent( | 577 EXPECT_TRUE(net::LogContainsBeginEvent( |
| 568 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); | 578 log.entries(), 5, net::NetLog::TYPE_SSL_CONNECT)); |
| 569 | 579 |
| 570 // NSS has special handling that maps a handshake_failure alert received | 580 // NSS has special handling that maps a handshake_failure alert received |
| 571 // immediately after a client_hello to be a mismatched cipher suite error, | 581 // 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 | 582 // 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 | 583 // Secure Transport (OS X), the handshake_failure is bubbled up without any |
| 574 // interpretation, leading to ERR_SSL_PROTOCOL_ERROR. Either way, a failure | 584 // interpretation, leading to ERR_SSL_PROTOCOL_ERROR. Either way, a failure |
| 575 // indicates that no cipher suite was negotiated with the test server. | 585 // indicates that no cipher suite was negotiated with the test server. |
| 576 if (rv == net::ERR_IO_PENDING) | 586 if (rv == net::ERR_IO_PENDING) |
| 577 rv = callback.WaitForResult(); | 587 rv = callback.WaitForResult(); |
| 578 EXPECT_TRUE(rv == net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH || | 588 EXPECT_TRUE(rv == net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH || |
| 579 rv == net::ERR_SSL_PROTOCOL_ERROR); | 589 rv == net::ERR_SSL_PROTOCOL_ERROR); |
| 580 // The exact ordering differs between SSLClientSocketNSS (which issues an | 590 // The exact ordering differs between SSLClientSocketNSS (which issues an |
| 581 // extra read) and SSLClientSocketMac (which does not). Just make sure the | 591 // extra read) and SSLClientSocketMac (which does not). Just make sure the |
| 582 // error appears somewhere in the log. | 592 // error appears somewhere in the log. |
| 583 net::ExpectLogContainsSomewhere(log.entries(), 0, | 593 net::ExpectLogContainsSomewhere(log.entries(), 0, |
| 584 net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 594 net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| 585 net::NetLog::PHASE_NONE); | 595 net::NetLog::PHASE_NONE); |
| 586 | 596 |
| 587 // We cannot test sock->IsConnected(), as the NSS implementation disconnects | 597 // We cannot test sock->IsConnected(), as the NSS implementation disconnects |
| 588 // the socket when it encounters an error, whereas other implementations | 598 // the socket when it encounters an error, whereas other implementations |
| 589 // leave it connected. | 599 // leave it connected. |
| 590 EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); | 600 EXPECT_TRUE(LogContainsSSLConnectEndEvent(log.entries(), -1)); |
| 591 } | 601 } |
| OLD | NEW |