| 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 "net/base/address_list.h" | 7 #include "net/base/address_list.h" |
| 8 #include "net/base/cert_test_util.h" | 8 #include "net/base/cert_test_util.h" |
| 9 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 TEST_F(SSLClientSocketTest, Connect) { | 72 TEST_F(SSLClientSocketTest, Connect) { |
| 73 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 73 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 74 net::TestServer::kLocalhost, | 74 net::TestServer::kLocalhost, |
| 75 FilePath()); | 75 FilePath()); |
| 76 ASSERT_TRUE(test_server.Start()); | 76 ASSERT_TRUE(test_server.Start()); |
| 77 | 77 |
| 78 net::AddressList addr; | 78 net::AddressList addr; |
| 79 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 79 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 80 | 80 |
| 81 net::TestCompletionCallback callback; | 81 net::TestCompletionCallback callback; |
| 82 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 82 net::CapturingNetLog log; |
| 83 net::StreamSocket* transport = new net::TCPClientSocket( | 83 net::StreamSocket* transport = new net::TCPClientSocket( |
| 84 addr, &log, net::NetLog::Source()); | 84 addr, &log, net::NetLog::Source()); |
| 85 int rv = transport->Connect(callback.callback()); | 85 int rv = transport->Connect(callback.callback()); |
| 86 if (rv == net::ERR_IO_PENDING) | 86 if (rv == net::ERR_IO_PENDING) |
| 87 rv = callback.WaitForResult(); | 87 rv = callback.WaitForResult(); |
| 88 EXPECT_EQ(net::OK, rv); | 88 EXPECT_EQ(net::OK, rv); |
| 89 | 89 |
| 90 scoped_ptr<net::SSLClientSocket> sock( | 90 scoped_ptr<net::SSLClientSocket> sock( |
| 91 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 91 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 92 kDefaultSSLConfig)); | 92 kDefaultSSLConfig)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 net::TestServer::HTTPSOptions::CERT_EXPIRED); | 115 net::TestServer::HTTPSOptions::CERT_EXPIRED); |
| 116 net::TestServer test_server(https_options, FilePath()); | 116 net::TestServer test_server(https_options, FilePath()); |
| 117 ASSERT_TRUE(test_server.Start()); | 117 ASSERT_TRUE(test_server.Start()); |
| 118 | 118 |
| 119 cert_verifier_->set_default_result(net::ERR_CERT_DATE_INVALID); | 119 cert_verifier_->set_default_result(net::ERR_CERT_DATE_INVALID); |
| 120 | 120 |
| 121 net::AddressList addr; | 121 net::AddressList addr; |
| 122 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 122 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 123 | 123 |
| 124 net::TestCompletionCallback callback; | 124 net::TestCompletionCallback callback; |
| 125 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 125 net::CapturingNetLog log; |
| 126 net::StreamSocket* transport = new net::TCPClientSocket( | 126 net::StreamSocket* transport = new net::TCPClientSocket( |
| 127 addr, &log, net::NetLog::Source()); | 127 addr, &log, net::NetLog::Source()); |
| 128 int rv = transport->Connect(callback.callback()); | 128 int rv = transport->Connect(callback.callback()); |
| 129 if (rv == net::ERR_IO_PENDING) | 129 if (rv == net::ERR_IO_PENDING) |
| 130 rv = callback.WaitForResult(); | 130 rv = callback.WaitForResult(); |
| 131 EXPECT_EQ(net::OK, rv); | 131 EXPECT_EQ(net::OK, rv); |
| 132 | 132 |
| 133 scoped_ptr<net::SSLClientSocket> sock( | 133 scoped_ptr<net::SSLClientSocket> sock( |
| 134 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 134 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 135 kDefaultSSLConfig)); | 135 kDefaultSSLConfig)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 160 net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME); | 160 net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME); |
| 161 net::TestServer test_server(https_options, FilePath()); | 161 net::TestServer test_server(https_options, FilePath()); |
| 162 ASSERT_TRUE(test_server.Start()); | 162 ASSERT_TRUE(test_server.Start()); |
| 163 | 163 |
| 164 cert_verifier_->set_default_result(net::ERR_CERT_COMMON_NAME_INVALID); | 164 cert_verifier_->set_default_result(net::ERR_CERT_COMMON_NAME_INVALID); |
| 165 | 165 |
| 166 net::AddressList addr; | 166 net::AddressList addr; |
| 167 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 167 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 168 | 168 |
| 169 net::TestCompletionCallback callback; | 169 net::TestCompletionCallback callback; |
| 170 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 170 net::CapturingNetLog log; |
| 171 net::StreamSocket* transport = new net::TCPClientSocket( | 171 net::StreamSocket* transport = new net::TCPClientSocket( |
| 172 addr, &log, net::NetLog::Source()); | 172 addr, &log, net::NetLog::Source()); |
| 173 int rv = transport->Connect(callback.callback()); | 173 int rv = transport->Connect(callback.callback()); |
| 174 if (rv == net::ERR_IO_PENDING) | 174 if (rv == net::ERR_IO_PENDING) |
| 175 rv = callback.WaitForResult(); | 175 rv = callback.WaitForResult(); |
| 176 EXPECT_EQ(net::OK, rv); | 176 EXPECT_EQ(net::OK, rv); |
| 177 | 177 |
| 178 scoped_ptr<net::SSLClientSocket> sock( | 178 scoped_ptr<net::SSLClientSocket> sock( |
| 179 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 179 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 180 kDefaultSSLConfig)); | 180 kDefaultSSLConfig)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 205 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { | 205 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { |
| 206 net::TestServer::HTTPSOptions https_options; | 206 net::TestServer::HTTPSOptions https_options; |
| 207 https_options.request_client_certificate = true; | 207 https_options.request_client_certificate = true; |
| 208 net::TestServer test_server(https_options, FilePath()); | 208 net::TestServer test_server(https_options, FilePath()); |
| 209 ASSERT_TRUE(test_server.Start()); | 209 ASSERT_TRUE(test_server.Start()); |
| 210 | 210 |
| 211 net::AddressList addr; | 211 net::AddressList addr; |
| 212 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 212 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 213 | 213 |
| 214 net::TestCompletionCallback callback; | 214 net::TestCompletionCallback callback; |
| 215 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 215 net::CapturingNetLog log; |
| 216 net::StreamSocket* transport = new net::TCPClientSocket( | 216 net::StreamSocket* transport = new net::TCPClientSocket( |
| 217 addr, &log, net::NetLog::Source()); | 217 addr, &log, net::NetLog::Source()); |
| 218 int rv = transport->Connect(callback.callback()); | 218 int rv = transport->Connect(callback.callback()); |
| 219 if (rv == net::ERR_IO_PENDING) | 219 if (rv == net::ERR_IO_PENDING) |
| 220 rv = callback.WaitForResult(); | 220 rv = callback.WaitForResult(); |
| 221 EXPECT_EQ(net::OK, rv); | 221 EXPECT_EQ(net::OK, rv); |
| 222 | 222 |
| 223 scoped_ptr<net::SSLClientSocket> sock( | 223 scoped_ptr<net::SSLClientSocket> sock( |
| 224 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 224 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 225 kDefaultSSLConfig)); | 225 kDefaultSSLConfig)); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { | 265 TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { |
| 266 net::TestServer::HTTPSOptions https_options; | 266 net::TestServer::HTTPSOptions https_options; |
| 267 https_options.request_client_certificate = true; | 267 https_options.request_client_certificate = true; |
| 268 net::TestServer test_server(https_options, FilePath()); | 268 net::TestServer test_server(https_options, FilePath()); |
| 269 ASSERT_TRUE(test_server.Start()); | 269 ASSERT_TRUE(test_server.Start()); |
| 270 | 270 |
| 271 net::AddressList addr; | 271 net::AddressList addr; |
| 272 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 272 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 273 | 273 |
| 274 net::TestCompletionCallback callback; | 274 net::TestCompletionCallback callback; |
| 275 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 275 net::CapturingNetLog log; |
| 276 net::StreamSocket* transport = new net::TCPClientSocket( | 276 net::StreamSocket* transport = new net::TCPClientSocket( |
| 277 addr, &log, net::NetLog::Source()); | 277 addr, &log, net::NetLog::Source()); |
| 278 int rv = transport->Connect(callback.callback()); | 278 int rv = transport->Connect(callback.callback()); |
| 279 if (rv == net::ERR_IO_PENDING) | 279 if (rv == net::ERR_IO_PENDING) |
| 280 rv = callback.WaitForResult(); | 280 rv = callback.WaitForResult(); |
| 281 EXPECT_EQ(net::OK, rv); | 281 EXPECT_EQ(net::OK, rv); |
| 282 | 282 |
| 283 net::SSLConfig ssl_config = kDefaultSSLConfig; | 283 net::SSLConfig ssl_config = kDefaultSSLConfig; |
| 284 ssl_config.send_client_cert = true; | 284 ssl_config.send_client_cert = true; |
| 285 ssl_config.client_cert = NULL; | 285 ssl_config.client_cert = NULL; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 TEST_F(SSLClientSocketTest, Read_FullLogging) { | 542 TEST_F(SSLClientSocketTest, Read_FullLogging) { |
| 543 net::TestServer test_server(net::TestServer::TYPE_HTTPS, | 543 net::TestServer test_server(net::TestServer::TYPE_HTTPS, |
| 544 net::TestServer::kLocalhost, | 544 net::TestServer::kLocalhost, |
| 545 FilePath()); | 545 FilePath()); |
| 546 ASSERT_TRUE(test_server.Start()); | 546 ASSERT_TRUE(test_server.Start()); |
| 547 | 547 |
| 548 net::AddressList addr; | 548 net::AddressList addr; |
| 549 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 549 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 550 | 550 |
| 551 net::TestCompletionCallback callback; | 551 net::TestCompletionCallback callback; |
| 552 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 552 net::CapturingNetLog log; |
| 553 log.SetLogLevel(net::NetLog::LOG_ALL); | 553 log.SetLogLevel(net::NetLog::LOG_ALL); |
| 554 net::StreamSocket* transport = new net::TCPClientSocket( | 554 net::StreamSocket* transport = new net::TCPClientSocket( |
| 555 addr, &log, net::NetLog::Source()); | 555 addr, &log, net::NetLog::Source()); |
| 556 int rv = transport->Connect(callback.callback()); | 556 int rv = transport->Connect(callback.callback()); |
| 557 if (rv == net::ERR_IO_PENDING) | 557 if (rv == net::ERR_IO_PENDING) |
| 558 rv = callback.WaitForResult(); | 558 rv = callback.WaitForResult(); |
| 559 EXPECT_EQ(net::OK, rv); | 559 EXPECT_EQ(net::OK, rv); |
| 560 | 560 |
| 561 scoped_ptr<net::SSLClientSocket> sock( | 561 scoped_ptr<net::SSLClientSocket> sock( |
| 562 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 562 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 // Enable only RC4 on the test server. | 670 // Enable only RC4 on the test server. |
| 671 https_options.bulk_ciphers = | 671 https_options.bulk_ciphers = |
| 672 net::TestServer::HTTPSOptions::BULK_CIPHER_RC4; | 672 net::TestServer::HTTPSOptions::BULK_CIPHER_RC4; |
| 673 net::TestServer test_server(https_options, FilePath()); | 673 net::TestServer test_server(https_options, FilePath()); |
| 674 ASSERT_TRUE(test_server.Start()); | 674 ASSERT_TRUE(test_server.Start()); |
| 675 | 675 |
| 676 net::AddressList addr; | 676 net::AddressList addr; |
| 677 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 677 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 678 | 678 |
| 679 net::TestCompletionCallback callback; | 679 net::TestCompletionCallback callback; |
| 680 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 680 net::CapturingNetLog log; |
| 681 net::StreamSocket* transport = new net::TCPClientSocket( | 681 net::StreamSocket* transport = new net::TCPClientSocket( |
| 682 addr, &log, net::NetLog::Source()); | 682 addr, &log, net::NetLog::Source()); |
| 683 int rv = transport->Connect(callback.callback()); | 683 int rv = transport->Connect(callback.callback()); |
| 684 if (rv == net::ERR_IO_PENDING) | 684 if (rv == net::ERR_IO_PENDING) |
| 685 rv = callback.WaitForResult(); | 685 rv = callback.WaitForResult(); |
| 686 EXPECT_EQ(net::OK, rv); | 686 EXPECT_EQ(net::OK, rv); |
| 687 | 687 |
| 688 net::SSLConfig ssl_config; | 688 net::SSLConfig ssl_config; |
| 689 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 689 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) |
| 690 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 690 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 net::TestServer::HTTPSOptions https_options( | 871 net::TestServer::HTTPSOptions https_options( |
| 872 net::TestServer::HTTPSOptions::CERT_CHAIN_WRONG_ROOT); | 872 net::TestServer::HTTPSOptions::CERT_CHAIN_WRONG_ROOT); |
| 873 net::TestServer test_server(https_options, | 873 net::TestServer test_server(https_options, |
| 874 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 874 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 875 ASSERT_TRUE(test_server.Start()); | 875 ASSERT_TRUE(test_server.Start()); |
| 876 | 876 |
| 877 net::AddressList addr; | 877 net::AddressList addr; |
| 878 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 878 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 879 | 879 |
| 880 net::TestCompletionCallback callback; | 880 net::TestCompletionCallback callback; |
| 881 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 881 net::CapturingNetLog log; |
| 882 net::StreamSocket* transport = new net::TCPClientSocket( | 882 net::StreamSocket* transport = new net::TCPClientSocket( |
| 883 addr, &log, net::NetLog::Source()); | 883 addr, &log, net::NetLog::Source()); |
| 884 int rv = transport->Connect(callback.callback()); | 884 int rv = transport->Connect(callback.callback()); |
| 885 if (rv == net::ERR_IO_PENDING) | 885 if (rv == net::ERR_IO_PENDING) |
| 886 rv = callback.WaitForResult(); | 886 rv = callback.WaitForResult(); |
| 887 EXPECT_EQ(net::OK, rv); | 887 EXPECT_EQ(net::OK, rv); |
| 888 | 888 |
| 889 scoped_ptr<net::SSLClientSocket> sock( | 889 scoped_ptr<net::SSLClientSocket> sock( |
| 890 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 890 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 891 kDefaultSSLConfig)); | 891 kDefaultSSLConfig)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 916 ssl_info.cert->os_cert_handle(), certs[0]->os_cert_handle())); | 916 ssl_info.cert->os_cert_handle(), certs[0]->os_cert_handle())); |
| 917 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( | 917 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( |
| 918 intermediates[0], certs[1]->os_cert_handle())); | 918 intermediates[0], certs[1]->os_cert_handle())); |
| 919 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( | 919 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( |
| 920 intermediates[1], certs[2]->os_cert_handle())); | 920 intermediates[1], certs[2]->os_cert_handle())); |
| 921 | 921 |
| 922 sock->Disconnect(); | 922 sock->Disconnect(); |
| 923 EXPECT_FALSE(sock->IsConnected()); | 923 EXPECT_FALSE(sock->IsConnected()); |
| 924 } | 924 } |
| 925 | 925 |
| OLD | NEW |