| OLD | NEW |
| 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/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
| 9 #include "net/base/cert_test_util.h" | 9 #include "net/base/cert_test_util.h" |
| 10 #include "net/base/host_resolver.h" | 10 #include "net/base/host_resolver.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 static bool LogContainsSSLConnectEndEvent( | 67 static bool LogContainsSSLConnectEndEvent( |
| 68 const net::CapturingNetLog::CapturedEntryList& log, int i) { | 68 const net::CapturingNetLog::CapturedEntryList& log, int i) { |
| 69 return net::LogContainsEndEvent(log, i, net::NetLog::TYPE_SSL_CONNECT) || | 69 return net::LogContainsEndEvent(log, i, net::NetLog::TYPE_SSL_CONNECT) || |
| 70 net::LogContainsEvent(log, i, net::NetLog::TYPE_SOCKET_BYTES_SENT, | 70 net::LogContainsEvent(log, i, net::NetLog::TYPE_SOCKET_BYTES_SENT, |
| 71 net::NetLog::PHASE_NONE); | 71 net::NetLog::PHASE_NONE); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 TEST_F(SSLClientSocketTest, Connect) { | 74 TEST_F(SSLClientSocketTest, Connect) { |
| 75 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 75 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 76 net::TestServer::kLocalhost, | 76 net::TestServer::kLocalhost, |
| 77 base::FilePath()); | 77 net::TestServer::GetSourcePath()); |
| 78 ASSERT_TRUE(test_server.Start()); | 78 ASSERT_TRUE(test_server.Start()); |
| 79 | 79 |
| 80 net::AddressList addr; | 80 net::AddressList addr; |
| 81 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 81 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 82 | 82 |
| 83 net::TestCompletionCallback callback; | 83 net::TestCompletionCallback callback; |
| 84 net::CapturingNetLog log; | 84 net::CapturingNetLog log; |
| 85 net::StreamSocket* transport = new net::TCPClientSocket( | 85 net::StreamSocket* transport = new net::TCPClientSocket( |
| 86 addr, &log, net::NetLog::Source()); | 86 addr, &log, net::NetLog::Source()); |
| 87 int rv = transport->Connect(callback.callback()); | 87 int rv = transport->Connect(callback.callback()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 110 | 110 |
| 111 sock->Disconnect(); | 111 sock->Disconnect(); |
| 112 EXPECT_FALSE(sock->IsConnected()); | 112 EXPECT_FALSE(sock->IsConnected()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST_F(SSLClientSocketTest, ConnectExpired) { | 115 TEST_F(SSLClientSocketTest, ConnectExpired) { |
| 116 net::TestServer::SSLOptions ssl_options( | 116 net::TestServer::SSLOptions ssl_options( |
| 117 net::TestServer::SSLOptions::CERT_EXPIRED); | 117 net::TestServer::SSLOptions::CERT_EXPIRED); |
| 118 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 118 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 119 ssl_options, | 119 ssl_options, |
| 120 base::FilePath()); | 120 net::TestServer::GetSourcePath()); |
| 121 ASSERT_TRUE(test_server.Start()); | 121 ASSERT_TRUE(test_server.Start()); |
| 122 | 122 |
| 123 cert_verifier_->set_default_result(net::ERR_CERT_DATE_INVALID); | 123 cert_verifier_->set_default_result(net::ERR_CERT_DATE_INVALID); |
| 124 | 124 |
| 125 net::AddressList addr; | 125 net::AddressList addr; |
| 126 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 126 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 127 | 127 |
| 128 net::TestCompletionCallback callback; | 128 net::TestCompletionCallback callback; |
| 129 net::CapturingNetLog log; | 129 net::CapturingNetLog log; |
| 130 net::StreamSocket* transport = new net::TCPClientSocket( | 130 net::StreamSocket* transport = new net::TCPClientSocket( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 157 // the user may take indefinitely long to respond. | 157 // the user may take indefinitely long to respond. |
| 158 log.GetEntries(&entries); | 158 log.GetEntries(&entries); |
| 159 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); | 159 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST_F(SSLClientSocketTest, ConnectMismatched) { | 162 TEST_F(SSLClientSocketTest, ConnectMismatched) { |
| 163 net::TestServer::SSLOptions ssl_options( | 163 net::TestServer::SSLOptions ssl_options( |
| 164 net::TestServer::SSLOptions::CERT_MISMATCHED_NAME); | 164 net::TestServer::SSLOptions::CERT_MISMATCHED_NAME); |
| 165 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 165 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 166 ssl_options, | 166 ssl_options, |
| 167 base::FilePath()); | 167 net::TestServer::GetSourcePath()); |
| 168 ASSERT_TRUE(test_server.Start()); | 168 ASSERT_TRUE(test_server.Start()); |
| 169 | 169 |
| 170 cert_verifier_->set_default_result(net::ERR_CERT_COMMON_NAME_INVALID); | 170 cert_verifier_->set_default_result(net::ERR_CERT_COMMON_NAME_INVALID); |
| 171 | 171 |
| 172 net::AddressList addr; | 172 net::AddressList addr; |
| 173 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 173 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 174 | 174 |
| 175 net::TestCompletionCallback callback; | 175 net::TestCompletionCallback callback; |
| 176 net::CapturingNetLog log; | 176 net::CapturingNetLog log; |
| 177 net::StreamSocket* transport = new net::TCPClientSocket( | 177 net::StreamSocket* transport = new net::TCPClientSocket( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 206 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); | 206 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Attempt to connect to a page which requests a client certificate. It should | 209 // Attempt to connect to a page which requests a client certificate. It should |
| 210 // return an error code on connect. | 210 // return an error code on connect. |
| 211 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { | 211 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { |
| 212 net::TestServer::SSLOptions ssl_options; | 212 net::TestServer::SSLOptions ssl_options; |
| 213 ssl_options.request_client_certificate = true; | 213 ssl_options.request_client_certificate = true; |
| 214 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 214 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 215 ssl_options, | 215 ssl_options, |
| 216 base::FilePath()); | 216 net::TestServer::GetSourcePath()); |
| 217 ASSERT_TRUE(test_server.Start()); | 217 ASSERT_TRUE(test_server.Start()); |
| 218 | 218 |
| 219 net::AddressList addr; | 219 net::AddressList addr; |
| 220 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 220 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 221 | 221 |
| 222 net::TestCompletionCallback callback; | 222 net::TestCompletionCallback callback; |
| 223 net::CapturingNetLog log; | 223 net::CapturingNetLog log; |
| 224 net::StreamSocket* transport = new net::TCPClientSocket( | 224 net::StreamSocket* transport = new net::TCPClientSocket( |
| 225 addr, &log, net::NetLog::Source()); | 225 addr, &log, net::NetLog::Source()); |
| 226 int rv = transport->Connect(callback.callback()); | 226 int rv = transport->Connect(callback.callback()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 268 |
| 269 // Connect to a server requesting optional client authentication. Send it a | 269 // Connect to a server requesting optional client authentication. Send it a |
| 270 // null certificate. It should allow the connection. | 270 // null certificate. It should allow the connection. |
| 271 // | 271 // |
| 272 // TODO(davidben): Also test providing an actual certificate. | 272 // TODO(davidben): Also test providing an actual certificate. |
| 273 TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { | 273 TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { |
| 274 net::TestServer::SSLOptions ssl_options; | 274 net::TestServer::SSLOptions ssl_options; |
| 275 ssl_options.request_client_certificate = true; | 275 ssl_options.request_client_certificate = true; |
| 276 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 276 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 277 ssl_options, | 277 ssl_options, |
| 278 base::FilePath()); | 278 net::TestServer::GetSourcePath()); |
| 279 ASSERT_TRUE(test_server.Start()); | 279 ASSERT_TRUE(test_server.Start()); |
| 280 | 280 |
| 281 net::AddressList addr; | 281 net::AddressList addr; |
| 282 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 282 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 283 | 283 |
| 284 net::TestCompletionCallback callback; | 284 net::TestCompletionCallback callback; |
| 285 net::CapturingNetLog log; | 285 net::CapturingNetLog log; |
| 286 net::StreamSocket* transport = new net::TCPClientSocket( | 286 net::StreamSocket* transport = new net::TCPClientSocket( |
| 287 addr, &log, net::NetLog::Source()); | 287 addr, &log, net::NetLog::Source()); |
| 288 int rv = transport->Connect(callback.callback()); | 288 int rv = transport->Connect(callback.callback()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 // TODO(wtc): Add unit tests for IsConnectedAndIdle: | 330 // TODO(wtc): Add unit tests for IsConnectedAndIdle: |
| 331 // - Server closes an SSL connection (with a close_notify alert message). | 331 // - Server closes an SSL connection (with a close_notify alert message). |
| 332 // - Server closes the underlying TCP connection directly. | 332 // - Server closes the underlying TCP connection directly. |
| 333 // - Server sends data unexpectedly. | 333 // - Server sends data unexpectedly. |
| 334 | 334 |
| 335 TEST_F(SSLClientSocketTest, Read) { | 335 TEST_F(SSLClientSocketTest, Read) { |
| 336 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 336 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 337 net::TestServer::kLocalhost, | 337 net::TestServer::kLocalhost, |
| 338 base::FilePath()); | 338 net::TestServer::GetSourcePath()); |
| 339 ASSERT_TRUE(test_server.Start()); | 339 ASSERT_TRUE(test_server.Start()); |
| 340 | 340 |
| 341 net::AddressList addr; | 341 net::AddressList addr; |
| 342 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 342 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 343 | 343 |
| 344 net::TestCompletionCallback callback; | 344 net::TestCompletionCallback callback; |
| 345 net::StreamSocket* transport = new net::TCPClientSocket( | 345 net::StreamSocket* transport = new net::TCPClientSocket( |
| 346 addr, NULL, net::NetLog::Source()); | 346 addr, NULL, net::NetLog::Source()); |
| 347 int rv = transport->Connect(callback.callback()); | 347 int rv = transport->Connect(callback.callback()); |
| 348 if (rv == net::ERR_IO_PENDING) | 348 if (rv == net::ERR_IO_PENDING) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 if (rv <= 0) | 384 if (rv <= 0) |
| 385 break; | 385 break; |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Test the full duplex mode, with Read and Write pending at the same time. | 389 // Test the full duplex mode, with Read and Write pending at the same time. |
| 390 // This test also serves as a regression test for http://crbug.com/29815. | 390 // This test also serves as a regression test for http://crbug.com/29815. |
| 391 TEST_F(SSLClientSocketTest, Read_FullDuplex) { | 391 TEST_F(SSLClientSocketTest, Read_FullDuplex) { |
| 392 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 392 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 393 net::TestServer::kLocalhost, | 393 net::TestServer::kLocalhost, |
| 394 base::FilePath()); | 394 net::TestServer::GetSourcePath()); |
| 395 ASSERT_TRUE(test_server.Start()); | 395 ASSERT_TRUE(test_server.Start()); |
| 396 | 396 |
| 397 net::AddressList addr; | 397 net::AddressList addr; |
| 398 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 398 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 399 | 399 |
| 400 net::TestCompletionCallback callback; // Used for everything except Write. | 400 net::TestCompletionCallback callback; // Used for everything except Write. |
| 401 | 401 |
| 402 net::StreamSocket* transport = new net::TCPClientSocket( | 402 net::StreamSocket* transport = new net::TCPClientSocket( |
| 403 addr, NULL, net::NetLog::Source()); | 403 addr, NULL, net::NetLog::Source()); |
| 404 int rv = transport->Connect(callback.callback()); | 404 int rv = transport->Connect(callback.callback()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 EXPECT_EQ(static_cast<int>(request_text.size()), rv); | 442 EXPECT_EQ(static_cast<int>(request_text.size()), rv); |
| 443 | 443 |
| 444 // Now get the Read result. | 444 // Now get the Read result. |
| 445 rv = callback.WaitForResult(); | 445 rv = callback.WaitForResult(); |
| 446 EXPECT_GT(rv, 0); | 446 EXPECT_GT(rv, 0); |
| 447 } | 447 } |
| 448 | 448 |
| 449 TEST_F(SSLClientSocketTest, Read_SmallChunks) { | 449 TEST_F(SSLClientSocketTest, Read_SmallChunks) { |
| 450 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 450 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 451 net::TestServer::kLocalhost, | 451 net::TestServer::kLocalhost, |
| 452 base::FilePath()); | 452 net::TestServer::GetSourcePath()); |
| 453 ASSERT_TRUE(test_server.Start()); | 453 ASSERT_TRUE(test_server.Start()); |
| 454 | 454 |
| 455 net::AddressList addr; | 455 net::AddressList addr; |
| 456 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 456 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 457 | 457 |
| 458 net::TestCompletionCallback callback; | 458 net::TestCompletionCallback callback; |
| 459 net::StreamSocket* transport = new net::TCPClientSocket( | 459 net::StreamSocket* transport = new net::TCPClientSocket( |
| 460 addr, NULL, net::NetLog::Source()); | 460 addr, NULL, net::NetLog::Source()); |
| 461 int rv = transport->Connect(callback.callback()); | 461 int rv = transport->Connect(callback.callback()); |
| 462 if (rv == net::ERR_IO_PENDING) | 462 if (rv == net::ERR_IO_PENDING) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 495 |
| 496 EXPECT_GE(rv, 0); | 496 EXPECT_GE(rv, 0); |
| 497 if (rv <= 0) | 497 if (rv <= 0) |
| 498 break; | 498 break; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 TEST_F(SSLClientSocketTest, Read_Interrupted) { | 502 TEST_F(SSLClientSocketTest, Read_Interrupted) { |
| 503 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 503 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 504 net::TestServer::kLocalhost, | 504 net::TestServer::kLocalhost, |
| 505 base::FilePath()); | 505 net::TestServer::GetSourcePath()); |
| 506 ASSERT_TRUE(test_server.Start()); | 506 ASSERT_TRUE(test_server.Start()); |
| 507 | 507 |
| 508 net::AddressList addr; | 508 net::AddressList addr; |
| 509 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 509 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 510 | 510 |
| 511 net::TestCompletionCallback callback; | 511 net::TestCompletionCallback callback; |
| 512 net::StreamSocket* transport = new net::TCPClientSocket( | 512 net::StreamSocket* transport = new net::TCPClientSocket( |
| 513 addr, NULL, net::NetLog::Source()); | 513 addr, NULL, net::NetLog::Source()); |
| 514 int rv = transport->Connect(callback.callback()); | 514 int rv = transport->Connect(callback.callback()); |
| 515 if (rv == net::ERR_IO_PENDING) | 515 if (rv == net::ERR_IO_PENDING) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 545 | 545 |
| 546 if (rv == net::ERR_IO_PENDING) | 546 if (rv == net::ERR_IO_PENDING) |
| 547 rv = callback.WaitForResult(); | 547 rv = callback.WaitForResult(); |
| 548 | 548 |
| 549 EXPECT_GT(rv, 0); | 549 EXPECT_GT(rv, 0); |
| 550 } | 550 } |
| 551 | 551 |
| 552 TEST_F(SSLClientSocketTest, Read_FullLogging) { | 552 TEST_F(SSLClientSocketTest, Read_FullLogging) { |
| 553 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 553 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 554 net::TestServer::kLocalhost, | 554 net::TestServer::kLocalhost, |
| 555 base::FilePath()); | 555 net::TestServer::GetSourcePath()); |
| 556 ASSERT_TRUE(test_server.Start()); | 556 ASSERT_TRUE(test_server.Start()); |
| 557 | 557 |
| 558 net::AddressList addr; | 558 net::AddressList addr; |
| 559 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 559 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 560 | 560 |
| 561 net::TestCompletionCallback callback; | 561 net::TestCompletionCallback callback; |
| 562 net::CapturingNetLog log; | 562 net::CapturingNetLog log; |
| 563 log.SetLogLevel(net::NetLog::LOG_ALL); | 563 log.SetLogLevel(net::NetLog::LOG_ALL); |
| 564 net::StreamSocket* transport = new net::TCPClientSocket( | 564 net::StreamSocket* transport = new net::TCPClientSocket( |
| 565 addr, &log, net::NetLog::Source()); | 565 addr, &log, net::NetLog::Source()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 last_index = net::ExpectLogContainsSomewhereAfter( | 613 last_index = net::ExpectLogContainsSomewhereAfter( |
| 614 entries, last_index + 1, net::NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, | 614 entries, last_index + 1, net::NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, |
| 615 net::NetLog::PHASE_NONE); | 615 net::NetLog::PHASE_NONE); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 | 618 |
| 619 // Regression test for http://crbug.com/42538 | 619 // Regression test for http://crbug.com/42538 |
| 620 TEST_F(SSLClientSocketTest, PrematureApplicationData) { | 620 TEST_F(SSLClientSocketTest, PrematureApplicationData) { |
| 621 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 621 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 622 net::TestServer::kLocalhost, | 622 net::TestServer::kLocalhost, |
| 623 base::FilePath()); | 623 net::TestServer::GetSourcePath()); |
| 624 ASSERT_TRUE(test_server.Start()); | 624 ASSERT_TRUE(test_server.Start()); |
| 625 | 625 |
| 626 net::AddressList addr; | 626 net::AddressList addr; |
| 627 net::TestCompletionCallback callback; | 627 net::TestCompletionCallback callback; |
| 628 | 628 |
| 629 static const unsigned char application_data[] = { | 629 static const unsigned char application_data[] = { |
| 630 0x17, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x46, 0x03, 0x01, 0x4b, | 630 0x17, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x46, 0x03, 0x01, 0x4b, |
| 631 0xc2, 0xf8, 0xb2, 0xc1, 0x56, 0x42, 0xb9, 0x57, 0x7f, 0xde, 0x87, 0x46, | 631 0xc2, 0xf8, 0xb2, 0xc1, 0x56, 0x42, 0xb9, 0x57, 0x7f, 0xde, 0x87, 0x46, |
| 632 0xf7, 0xa3, 0x52, 0x42, 0x21, 0xf0, 0x13, 0x1c, 0x9c, 0x83, 0x88, 0xd6, | 632 0xf7, 0xa3, 0x52, 0x42, 0x21, 0xf0, 0x13, 0x1c, 0x9c, 0x83, 0x88, 0xd6, |
| 633 0x93, 0x0c, 0xf6, 0x36, 0x30, 0x05, 0x7e, 0x20, 0xb5, 0xb5, 0x73, 0x36, | 633 0x93, 0x0c, 0xf6, 0x36, 0x30, 0x05, 0x7e, 0x20, 0xb5, 0xb5, 0x73, 0x36, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 const uint16 kCiphersToDisable[] = { | 677 const uint16 kCiphersToDisable[] = { |
| 678 0x0005, // TLS_RSA_WITH_RC4_128_SHA | 678 0x0005, // TLS_RSA_WITH_RC4_128_SHA |
| 679 }; | 679 }; |
| 680 | 680 |
| 681 net::TestServer::SSLOptions ssl_options; | 681 net::TestServer::SSLOptions ssl_options; |
| 682 // Enable only RC4 on the test server. | 682 // Enable only RC4 on the test server. |
| 683 ssl_options.bulk_ciphers = | 683 ssl_options.bulk_ciphers = |
| 684 net::TestServer::SSLOptions::BULK_CIPHER_RC4; | 684 net::TestServer::SSLOptions::BULK_CIPHER_RC4; |
| 685 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 685 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 686 ssl_options, | 686 ssl_options, |
| 687 base::FilePath()); | 687 net::TestServer::GetSourcePath()); |
| 688 ASSERT_TRUE(test_server.Start()); | 688 ASSERT_TRUE(test_server.Start()); |
| 689 | 689 |
| 690 net::AddressList addr; | 690 net::AddressList addr; |
| 691 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 691 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 692 | 692 |
| 693 net::TestCompletionCallback callback; | 693 net::TestCompletionCallback callback; |
| 694 net::CapturingNetLog log; | 694 net::CapturingNetLog log; |
| 695 net::StreamSocket* transport = new net::TCPClientSocket( | 695 net::StreamSocket* transport = new net::TCPClientSocket( |
| 696 addr, &log, net::NetLog::Source()); | 696 addr, &log, net::NetLog::Source()); |
| 697 int rv = transport->Connect(callback.callback()); | 697 int rv = transport->Connect(callback.callback()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 LogContainsSSLConnectEndEvent(entries, -2)); | 748 LogContainsSSLConnectEndEvent(entries, -2)); |
| 749 } | 749 } |
| 750 | 750 |
| 751 // When creating an SSLClientSocket, it is allowed to pass in a | 751 // When creating an SSLClientSocket, it is allowed to pass in a |
| 752 // ClientSocketHandle that is not obtained from a client socket pool. | 752 // ClientSocketHandle that is not obtained from a client socket pool. |
| 753 // Here we verify that such a simple ClientSocketHandle, not associated with any | 753 // Here we verify that such a simple ClientSocketHandle, not associated with any |
| 754 // client socket pool, can be destroyed safely. | 754 // client socket pool, can be destroyed safely. |
| 755 TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) { | 755 TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) { |
| 756 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 756 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 757 net::TestServer::kLocalhost, | 757 net::TestServer::kLocalhost, |
| 758 base::FilePath()); | 758 net::TestServer::GetSourcePath()); |
| 759 ASSERT_TRUE(test_server.Start()); | 759 ASSERT_TRUE(test_server.Start()); |
| 760 | 760 |
| 761 net::AddressList addr; | 761 net::AddressList addr; |
| 762 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 762 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 763 | 763 |
| 764 net::TestCompletionCallback callback; | 764 net::TestCompletionCallback callback; |
| 765 net::StreamSocket* transport = new net::TCPClientSocket( | 765 net::StreamSocket* transport = new net::TCPClientSocket( |
| 766 addr, NULL, net::NetLog::Source()); | 766 addr, NULL, net::NetLog::Source()); |
| 767 int rv = transport->Connect(callback.callback()); | 767 int rv = transport->Connect(callback.callback()); |
| 768 if (rv == net::ERR_IO_PENDING) | 768 if (rv == net::ERR_IO_PENDING) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 782 if (rv == net::ERR_IO_PENDING) | 782 if (rv == net::ERR_IO_PENDING) |
| 783 rv = callback.WaitForResult(); | 783 rv = callback.WaitForResult(); |
| 784 EXPECT_EQ(net::OK, rv); | 784 EXPECT_EQ(net::OK, rv); |
| 785 } | 785 } |
| 786 | 786 |
| 787 // Verifies that SSLClientSocket::ExportKeyingMaterial return a success | 787 // Verifies that SSLClientSocket::ExportKeyingMaterial return a success |
| 788 // code and different keying label results in different keying material. | 788 // code and different keying label results in different keying material. |
| 789 TEST_F(SSLClientSocketTest, ExportKeyingMaterial) { | 789 TEST_F(SSLClientSocketTest, ExportKeyingMaterial) { |
| 790 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 790 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 791 net::TestServer::kLocalhost, | 791 net::TestServer::kLocalhost, |
| 792 base::FilePath()); | 792 net::TestServer::GetSourcePath()); |
| 793 ASSERT_TRUE(test_server.Start()); | 793 ASSERT_TRUE(test_server.Start()); |
| 794 | 794 |
| 795 net::AddressList addr; | 795 net::AddressList addr; |
| 796 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 796 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 797 | 797 |
| 798 net::TestCompletionCallback callback; | 798 net::TestCompletionCallback callback; |
| 799 | 799 |
| 800 net::StreamSocket* transport = new net::TCPClientSocket( | 800 net::StreamSocket* transport = new net::TCPClientSocket( |
| 801 addr, NULL, net::NetLog::Source()); | 801 addr, NULL, net::NetLog::Source()); |
| 802 int rv = transport->Connect(callback.callback()); | 802 int rv = transport->Connect(callback.callback()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 net::ImportCertFromFile(net::GetTestCertsDirectory(), | 879 net::ImportCertFromFile(net::GetTestCertsDirectory(), |
| 880 "redundant-validated-chain-root.pem"); | 880 "redundant-validated-chain-root.pem"); |
| 881 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), root_cert); | 881 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), root_cert); |
| 882 net::ScopedTestRoot scoped_root(root_cert); | 882 net::ScopedTestRoot scoped_root(root_cert); |
| 883 | 883 |
| 884 // Set up a test server with CERT_CHAIN_WRONG_ROOT. | 884 // Set up a test server with CERT_CHAIN_WRONG_ROOT. |
| 885 net::TestServer::SSLOptions ssl_options( | 885 net::TestServer::SSLOptions ssl_options( |
| 886 net::TestServer::SSLOptions::CERT_CHAIN_WRONG_ROOT); | 886 net::TestServer::SSLOptions::CERT_CHAIN_WRONG_ROOT); |
| 887 net::TestServer test_server( | 887 net::TestServer test_server( |
| 888 net::TestServer::TYPE_HTTPS, ssl_options, | 888 net::TestServer::TYPE_HTTPS, ssl_options, |
| 889 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 889 net::TestServer::GetSourceRelativePath( |
| 890 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")))); |
| 890 ASSERT_TRUE(test_server.Start()); | 891 ASSERT_TRUE(test_server.Start()); |
| 891 | 892 |
| 892 net::AddressList addr; | 893 net::AddressList addr; |
| 893 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 894 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 894 | 895 |
| 895 net::TestCompletionCallback callback; | 896 net::TestCompletionCallback callback; |
| 896 net::CapturingNetLog log; | 897 net::CapturingNetLog log; |
| 897 net::StreamSocket* transport = new net::TCPClientSocket( | 898 net::StreamSocket* transport = new net::TCPClientSocket( |
| 898 addr, &log, net::NetLog::Source()); | 899 addr, &log, net::NetLog::Source()); |
| 899 int rv = transport->Connect(callback.callback()); | 900 int rv = transport->Connect(callback.callback()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 941 |
| 941 // Verifies the correctness of GetSSLCertRequestInfo. | 942 // Verifies the correctness of GetSSLCertRequestInfo. |
| 942 class SSLClientSocketCertRequestInfoTest : public SSLClientSocketTest { | 943 class SSLClientSocketCertRequestInfoTest : public SSLClientSocketTest { |
| 943 protected: | 944 protected: |
| 944 // Creates a test server with the given SSLOptions, connects to it and returns | 945 // Creates a test server with the given SSLOptions, connects to it and returns |
| 945 // the SSLCertRequestInfo reported by the socket. | 946 // the SSLCertRequestInfo reported by the socket. |
| 946 scoped_refptr<net::SSLCertRequestInfo> GetCertRequest( | 947 scoped_refptr<net::SSLCertRequestInfo> GetCertRequest( |
| 947 net::TestServer::SSLOptions ssl_options) { | 948 net::TestServer::SSLOptions ssl_options) { |
| 948 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 949 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 949 ssl_options, | 950 ssl_options, |
| 950 base::FilePath()); | 951 net::TestServer::GetSourcePath()); |
| 951 if (!test_server.Start()) | 952 if (!test_server.Start()) |
| 952 return NULL; | 953 return NULL; |
| 953 | 954 |
| 954 net::AddressList addr; | 955 net::AddressList addr; |
| 955 if (!test_server.GetAddressList(&addr)) | 956 if (!test_server.GetAddressList(&addr)) |
| 956 return NULL; | 957 return NULL; |
| 957 | 958 |
| 958 net::TestCompletionCallback callback; | 959 net::TestCompletionCallback callback; |
| 959 net::CapturingNetLog log; | 960 net::CapturingNetLog log; |
| 960 net::StreamSocket* transport = new net::TCPClientSocket( | 961 net::StreamSocket* transport = new net::TCPClientSocket( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 scoped_refptr<net::SSLCertRequestInfo> request_info = | 1041 scoped_refptr<net::SSLCertRequestInfo> request_info = |
| 1041 GetCertRequest(ssl_options); | 1042 GetCertRequest(ssl_options); |
| 1042 ASSERT_TRUE(request_info); | 1043 ASSERT_TRUE(request_info); |
| 1043 ASSERT_EQ(2u, request_info->cert_authorities.size()); | 1044 ASSERT_EQ(2u, request_info->cert_authorities.size()); |
| 1044 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), | 1045 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), |
| 1045 request_info->cert_authorities[0]); | 1046 request_info->cert_authorities[0]); |
| 1046 EXPECT_EQ( | 1047 EXPECT_EQ( |
| 1047 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), | 1048 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), |
| 1048 request_info->cert_authorities[1]); | 1049 request_info->cert_authorities[1]); |
| 1049 } | 1050 } |
| OLD | NEW |