| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 // Enable only RC4 on the test server. | 672 // Enable only RC4 on the test server. |
| 673 https_options.bulk_ciphers = | 673 https_options.bulk_ciphers = |
| 674 net::TestServer::HTTPSOptions::BULK_CIPHER_RC4; | 674 net::TestServer::HTTPSOptions::BULK_CIPHER_RC4; |
| 675 net::TestServer test_server(https_options, FilePath()); | 675 net::TestServer test_server(https_options, FilePath()); |
| 676 ASSERT_TRUE(test_server.Start()); | 676 ASSERT_TRUE(test_server.Start()); |
| 677 | 677 |
| 678 net::AddressList addr; | 678 net::AddressList addr; |
| 679 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 679 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 680 | 680 |
| 681 net::TestCompletionCallback callback; | 681 net::TestCompletionCallback callback; |
| 682 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 682 net::CapturingNetLog log; |
| 683 net::StreamSocket* transport = new net::TCPClientSocket( | 683 net::StreamSocket* transport = new net::TCPClientSocket( |
| 684 addr, &log, net::NetLog::Source()); | 684 addr, &log, net::NetLog::Source()); |
| 685 int rv = transport->Connect(callback.callback()); | 685 int rv = transport->Connect(callback.callback()); |
| 686 if (rv == net::ERR_IO_PENDING) | 686 if (rv == net::ERR_IO_PENDING) |
| 687 rv = callback.WaitForResult(); | 687 rv = callback.WaitForResult(); |
| 688 EXPECT_EQ(net::OK, rv); | 688 EXPECT_EQ(net::OK, rv); |
| 689 | 689 |
| 690 net::SSLConfig ssl_config; | 690 net::SSLConfig ssl_config; |
| 691 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 691 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) |
| 692 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 692 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 net::TestServer::HTTPSOptions https_options( | 873 net::TestServer::HTTPSOptions https_options( |
| 874 net::TestServer::HTTPSOptions::CERT_CHAIN_WRONG_ROOT); | 874 net::TestServer::HTTPSOptions::CERT_CHAIN_WRONG_ROOT); |
| 875 net::TestServer test_server(https_options, | 875 net::TestServer test_server(https_options, |
| 876 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 876 FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 877 ASSERT_TRUE(test_server.Start()); | 877 ASSERT_TRUE(test_server.Start()); |
| 878 | 878 |
| 879 net::AddressList addr; | 879 net::AddressList addr; |
| 880 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 880 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 881 | 881 |
| 882 net::TestCompletionCallback callback; | 882 net::TestCompletionCallback callback; |
| 883 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 883 net::CapturingNetLog log; |
| 884 net::StreamSocket* transport = new net::TCPClientSocket( | 884 net::StreamSocket* transport = new net::TCPClientSocket( |
| 885 addr, &log, net::NetLog::Source()); | 885 addr, &log, net::NetLog::Source()); |
| 886 int rv = transport->Connect(callback.callback()); | 886 int rv = transport->Connect(callback.callback()); |
| 887 if (rv == net::ERR_IO_PENDING) | 887 if (rv == net::ERR_IO_PENDING) |
| 888 rv = callback.WaitForResult(); | 888 rv = callback.WaitForResult(); |
| 889 EXPECT_EQ(net::OK, rv); | 889 EXPECT_EQ(net::OK, rv); |
| 890 | 890 |
| 891 scoped_ptr<net::SSLClientSocket> sock( | 891 scoped_ptr<net::SSLClientSocket> sock( |
| 892 CreateSSLClientSocket(transport, test_server.host_port_pair(), | 892 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 893 kDefaultSSLConfig)); | 893 kDefaultSSLConfig)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 918 ssl_info.cert->os_cert_handle(), certs[0]->os_cert_handle())); | 918 ssl_info.cert->os_cert_handle(), certs[0]->os_cert_handle())); |
| 919 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( | 919 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( |
| 920 intermediates[0], certs[1]->os_cert_handle())); | 920 intermediates[0], certs[1]->os_cert_handle())); |
| 921 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( | 921 EXPECT_TRUE(net::X509Certificate::IsSameOSCert( |
| 922 intermediates[1], certs[2]->os_cert_handle())); | 922 intermediates[1], certs[2]->os_cert_handle())); |
| 923 | 923 |
| 924 sock->Disconnect(); | 924 sock->Disconnect(); |
| 925 EXPECT_FALSE(sock->IsConnected()); | 925 EXPECT_FALSE(sock->IsConnected()); |
| 926 } | 926 } |
| 927 | 927 |
| OLD | NEW |