[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 5 | #include "net/socket/ssl_client_socket.h" |
| 6 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 7 | #include "net/base/address_list.h" |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 8 | #include "net/base/cert_verifier.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 9 | #include "net/base/host_resolver.h" |
[email protected] | 597cf6e | 2009-05-29 09:43:26 | [diff] [blame] | 10 | #include "net/base/io_buffer.h" |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 11 | #include "net/base/net_log.h" |
| 12 | #include "net/base/net_log_unittest.h" |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 13 | #include "net/base/net_errors.h" |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 14 | #include "net/base/ssl_config_service.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 15 | #include "net/base/test_completion_callback.h" |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 16 | #include "net/socket/client_socket_factory.h" |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 17 | #include "net/socket/client_socket_handle.h" |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 18 | #include "net/socket/socket_test_util.h" |
[email protected] | f7984fc6 | 2009-06-22 23:26:44 | [diff] [blame] | 19 | #include "net/socket/tcp_client_socket.h" |
[email protected] | 1b9565c | 2010-07-21 01:19:31 | [diff] [blame] | 20 | #include "net/test/test_server.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 21 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 23887f04f | 2008-12-02 19:20:15 | [diff] [blame] | 22 | #include "testing/platform_test.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 23 | |
| 24 | //----------------------------------------------------------------------------- |
| 25 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 26 | const net::SSLConfig kDefaultSSLConfig; |
[email protected] | c5949a3 | 2008-10-08 17:28:23 | [diff] [blame] | 27 | |
[email protected] | b75523f | 2008-10-17 14:49:07 | [diff] [blame] | 28 | class SSLClientSocketTest : public PlatformTest { |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 29 | public: |
| 30 | SSLClientSocketTest() |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 31 | : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()), |
| 32 | cert_verifier_(new net::CertVerifier) { |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 33 | } |
| 34 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 35 | protected: |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 36 | net::SSLClientSocket* CreateSSLClientSocket( |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 37 | net::StreamSocket* transport_socket, |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 38 | const net::HostPortPair& host_and_port, |
| 39 | const net::SSLConfig& ssl_config) { |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 40 | net::SSLClientSocketContext context; |
| 41 | context.cert_verifier = cert_verifier_.get(); |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 42 | return socket_factory_->CreateSSLClientSocket(transport_socket, |
| 43 | host_and_port, |
| 44 | ssl_config, |
| 45 | NULL, |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 46 | context); |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 47 | } |
| 48 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 49 | net::ClientSocketFactory* socket_factory_; |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 50 | scoped_ptr<net::CertVerifier> cert_verifier_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 51 | }; |
| 52 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 53 | //----------------------------------------------------------------------------- |
| 54 | |
[email protected] | 6a47ac8 | 2010-10-08 14:39:30 | [diff] [blame] | 55 | // LogContainsSSLConnectEndEvent returns true if the given index in the given |
| 56 | // log is an SSL connect end event. The NSS sockets will cork in an attempt to |
| 57 | // merge the first application data record with the Finished message when false |
| 58 | // starting. However, in order to avoid the server timing out the handshake, |
| 59 | // they'll give up waiting for application data and send the Finished after a |
| 60 | // timeout. This means that an SSL connect end event may appear as a socket |
| 61 | // write. |
| 62 | static bool LogContainsSSLConnectEndEvent( |
| 63 | const net::CapturingNetLog::EntryList& log, int i) { |
[email protected] | 7deea3d | 2011-01-09 06:03:41 | [diff] [blame] | 64 | return net::LogContainsEndEvent(log, i, net::NetLog::TYPE_SSL_CONNECT) || |
| 65 | net::LogContainsEvent(log, i, net::NetLog::TYPE_SOCKET_BYTES_SENT, |
[email protected] | 7f2fff1 | 2010-10-09 18:42:11 | [diff] [blame] | 66 | net::NetLog::PHASE_NONE); |
[email protected] | 6a47ac8 | 2010-10-08 14:39:30 | [diff] [blame] | 67 | }; |
| 68 | |
[email protected] | 010e27e | 2009-08-27 17:49:41 | [diff] [blame] | 69 | TEST_F(SSLClientSocketTest, Connect) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 70 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 71 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 72 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 73 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 74 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 75 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 76 | net::TestCompletionCallback callback; |
[email protected] | a2006ece | 2010-04-23 16:44:02 | [diff] [blame] | 77 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 78 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 79 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 80 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 81 | if (rv == net::ERR_IO_PENDING) |
| 82 | rv = callback.WaitForResult(); |
| 83 | EXPECT_EQ(net::OK, rv); |
| 84 | |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 85 | net::SSLClientSocketContext context; |
| 86 | context.cert_verifier = cert_verifier_.get(); |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 87 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 88 | socket_factory_->CreateSSLClientSocket( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 89 | transport, test_server.host_port_pair(), kDefaultSSLConfig, |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 90 | NULL, context)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 91 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 92 | EXPECT_FALSE(sock->IsConnected()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 93 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 94 | rv = sock->Connect(callback.callback()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 95 | |
| 96 | net::CapturingNetLog::EntryList entries; |
| 97 | log.GetEntries(&entries); |
[email protected] | eb8605c | 2010-05-21 22:17:47 | [diff] [blame] | 98 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 99 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 100 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 101 | rv = callback.WaitForResult(); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 102 | EXPECT_EQ(net::OK, rv); |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 103 | EXPECT_TRUE(sock->IsConnected()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 104 | log.GetEntries(&entries); |
| 105 | EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 106 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 107 | sock->Disconnect(); |
| 108 | EXPECT_FALSE(sock->IsConnected()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 109 | } |
| 110 | |
[email protected] | 7f2fff1 | 2010-10-09 18:42:11 | [diff] [blame] | 111 | TEST_F(SSLClientSocketTest, ConnectExpired) { |
[email protected] | 34759995 | 2010-10-28 11:57:36 | [diff] [blame] | 112 | net::TestServer::HTTPSOptions https_options( |
| 113 | net::TestServer::HTTPSOptions::CERT_EXPIRED); |
| 114 | net::TestServer test_server(https_options, FilePath()); |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 115 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 116 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 117 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 118 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 119 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 120 | net::TestCompletionCallback callback; |
[email protected] | a2006ece | 2010-04-23 16:44:02 | [diff] [blame] | 121 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 122 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 123 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 124 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 125 | if (rv == net::ERR_IO_PENDING) |
| 126 | rv = callback.WaitForResult(); |
| 127 | EXPECT_EQ(net::OK, rv); |
| 128 | |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 129 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 130 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 131 | kDefaultSSLConfig)); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 132 | |
| 133 | EXPECT_FALSE(sock->IsConnected()); |
| 134 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 135 | rv = sock->Connect(callback.callback()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 136 | |
| 137 | net::CapturingNetLog::EntryList entries; |
| 138 | log.GetEntries(&entries); |
[email protected] | eb8605c | 2010-05-21 22:17:47 | [diff] [blame] | 139 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 140 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 141 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 142 | rv = callback.WaitForResult(); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 143 | |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 144 | EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv); |
| 145 | |
| 146 | // Rather than testing whether or not the underlying socket is connected, |
| 147 | // test that the handshake has finished. This is because it may be |
| 148 | // desirable to disconnect the socket before showing a user prompt, since |
| 149 | // the user may take indefinitely long to respond. |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 150 | log.GetEntries(&entries); |
| 151 | EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 152 | } |
| 153 | |
[email protected] | 7f2fff1 | 2010-10-09 18:42:11 | [diff] [blame] | 154 | TEST_F(SSLClientSocketTest, ConnectMismatched) { |
[email protected] | 34759995 | 2010-10-28 11:57:36 | [diff] [blame] | 155 | net::TestServer::HTTPSOptions https_options( |
| 156 | net::TestServer::HTTPSOptions::CERT_MISMATCHED_NAME); |
| 157 | net::TestServer test_server(https_options, FilePath()); |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 158 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 159 | |
| 160 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 161 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 162 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 163 | net::TestCompletionCallback callback; |
[email protected] | a2006ece | 2010-04-23 16:44:02 | [diff] [blame] | 164 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 165 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 166 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 167 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 168 | if (rv == net::ERR_IO_PENDING) |
| 169 | rv = callback.WaitForResult(); |
| 170 | EXPECT_EQ(net::OK, rv); |
| 171 | |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 172 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 173 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 174 | kDefaultSSLConfig)); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 175 | |
| 176 | EXPECT_FALSE(sock->IsConnected()); |
| 177 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 178 | rv = sock->Connect(callback.callback()); |
[email protected] | 4b32be9 | 2010-05-20 03:21:42 | [diff] [blame] | 179 | |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 180 | net::CapturingNetLog::EntryList entries; |
| 181 | log.GetEntries(&entries); |
[email protected] | eb8605c | 2010-05-21 22:17:47 | [diff] [blame] | 182 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 183 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 184 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 185 | rv = callback.WaitForResult(); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 186 | |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 187 | EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, rv); |
| 188 | |
| 189 | // Rather than testing whether or not the underlying socket is connected, |
| 190 | // test that the handshake has finished. This is because it may be |
| 191 | // desirable to disconnect the socket before showing a user prompt, since |
| 192 | // the user may take indefinitely long to respond. |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 193 | log.GetEntries(&entries); |
| 194 | EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 195 | } |
| 196 | |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 197 | // Attempt to connect to a page which requests a client certificate. It should |
| 198 | // return an error code on connect. |
[email protected] | 091fd3b7 | 2011-03-14 03:23:52 | [diff] [blame] | 199 | TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { |
[email protected] | 34759995 | 2010-10-28 11:57:36 | [diff] [blame] | 200 | net::TestServer::HTTPSOptions https_options; |
| 201 | https_options.request_client_certificate = true; |
| 202 | net::TestServer test_server(https_options, FilePath()); |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 203 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 204 | |
| 205 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 206 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 207 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 208 | net::TestCompletionCallback callback; |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 209 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 210 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 211 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 212 | int rv = transport->Connect(callback.callback()); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 213 | if (rv == net::ERR_IO_PENDING) |
| 214 | rv = callback.WaitForResult(); |
| 215 | EXPECT_EQ(net::OK, rv); |
| 216 | |
| 217 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 218 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 219 | kDefaultSSLConfig)); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 220 | |
| 221 | EXPECT_FALSE(sock->IsConnected()); |
| 222 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 223 | rv = sock->Connect(callback.callback()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 224 | |
| 225 | net::CapturingNetLog::EntryList entries; |
| 226 | log.GetEntries(&entries); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 227 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 228 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 229 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 230 | rv = callback.WaitForResult(); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 231 | |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 232 | log.GetEntries(&entries); |
[email protected] | 091fd3b7 | 2011-03-14 03:23:52 | [diff] [blame] | 233 | // Because we prematurely kill the handshake at CertificateRequest, |
| 234 | // the server may still send data (notably the ServerHelloDone) |
| 235 | // after the error is returned. As a result, the SSL_CONNECT may not |
| 236 | // be the last entry. See http://crbug.com/54445. We use |
| 237 | // ExpectLogContainsSomewhere instead of |
| 238 | // LogContainsSSLConnectEndEvent to avoid assuming, e.g., only one |
| 239 | // extra read instead of two. This occurs before the handshake ends, |
| 240 | // so the corking logic of LogContainsSSLConnectEndEvent isn't |
| 241 | // necessary. |
| 242 | // |
| 243 | // TODO(davidben): When SSL_RestartHandshakeAfterCertReq in NSS is |
| 244 | // fixed and we can respond to the first CertificateRequest |
| 245 | // without closing the socket, add a unit test for sending the |
| 246 | // certificate. This test may still be useful as we'll want to close |
| 247 | // the socket on a timeout if the user takes a long time to pick a |
| 248 | // cert. Related bug: https://bugzilla.mozilla.org/show_bug.cgi?id=542832 |
| 249 | net::ExpectLogContainsSomewhere( |
| 250 | entries, 0, net::NetLog::TYPE_SSL_CONNECT, net::NetLog::PHASE_END); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 251 | EXPECT_EQ(net::ERR_SSL_CLIENT_AUTH_CERT_NEEDED, rv); |
| 252 | EXPECT_FALSE(sock->IsConnected()); |
[email protected] | 8df162a | 2010-08-07 01:10:02 | [diff] [blame] | 253 | } |
| 254 | |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 255 | // Connect to a server requesting optional client authentication. Send it a |
| 256 | // null certificate. It should allow the connection. |
| 257 | // |
| 258 | // TODO(davidben): Also test providing an actual certificate. |
| 259 | TEST_F(SSLClientSocketTest, ConnectClientAuthSendNullCert) { |
[email protected] | 34759995 | 2010-10-28 11:57:36 | [diff] [blame] | 260 | net::TestServer::HTTPSOptions https_options; |
| 261 | https_options.request_client_certificate = true; |
| 262 | net::TestServer test_server(https_options, FilePath()); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 263 | ASSERT_TRUE(test_server.Start()); |
| 264 | |
| 265 | net::AddressList addr; |
| 266 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 267 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 268 | net::TestCompletionCallback callback; |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 269 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 270 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 271 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 272 | int rv = transport->Connect(callback.callback()); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 273 | if (rv == net::ERR_IO_PENDING) |
| 274 | rv = callback.WaitForResult(); |
| 275 | EXPECT_EQ(net::OK, rv); |
| 276 | |
| 277 | net::SSLConfig ssl_config = kDefaultSSLConfig; |
| 278 | ssl_config.send_client_cert = true; |
| 279 | ssl_config.client_cert = NULL; |
| 280 | |
| 281 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 282 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 283 | ssl_config)); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 284 | |
| 285 | EXPECT_FALSE(sock->IsConnected()); |
| 286 | |
| 287 | // Our test server accepts certificate-less connections. |
| 288 | // TODO(davidben): Add a test which requires them and verify the error. |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 289 | rv = sock->Connect(callback.callback()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 290 | |
| 291 | net::CapturingNetLog::EntryList entries; |
| 292 | log.GetEntries(&entries); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 293 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 294 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 295 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 296 | rv = callback.WaitForResult(); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 297 | |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 298 | EXPECT_EQ(net::OK, rv); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 299 | EXPECT_TRUE(sock->IsConnected()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 300 | log.GetEntries(&entries); |
| 301 | EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 302 | |
[email protected] | 17a60a5 | 2011-10-28 01:18:10 | [diff] [blame] | 303 | // We responded to the server's certificate request with a Certificate |
| 304 | // message with no client certificate in it. ssl_info.client_cert_sent |
| 305 | // should be false in this case. |
| 306 | net::SSLInfo ssl_info; |
| 307 | sock->GetSSLInfo(&ssl_info); |
| 308 | EXPECT_FALSE(ssl_info.client_cert_sent); |
| 309 | |
[email protected] | 65a3b91 | 2010-08-21 05:46:58 | [diff] [blame] | 310 | sock->Disconnect(); |
| 311 | EXPECT_FALSE(sock->IsConnected()); |
| 312 | } |
| 313 | |
[email protected] | b219785 | 2009-02-19 23:27:33 | [diff] [blame] | 314 | // TODO(wtc): Add unit tests for IsConnectedAndIdle: |
| 315 | // - Server closes an SSL connection (with a close_notify alert message). |
| 316 | // - Server closes the underlying TCP connection directly. |
| 317 | // - Server sends data unexpectedly. |
| 318 | |
[email protected] | e3eb8f8 | 2010-09-21 15:25:15 | [diff] [blame] | 319 | TEST_F(SSLClientSocketTest, Read) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 320 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 321 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 322 | |
| 323 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 324 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 325 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 326 | net::TestCompletionCallback callback; |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 327 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 328 | addr, NULL, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 329 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 330 | if (rv == net::ERR_IO_PENDING) |
| 331 | rv = callback.WaitForResult(); |
| 332 | EXPECT_EQ(net::OK, rv); |
| 333 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 334 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 335 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 336 | kDefaultSSLConfig)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 337 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 338 | rv = sock->Connect(callback.callback()); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 339 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 340 | rv = callback.WaitForResult(); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 341 | EXPECT_EQ(net::OK, rv); |
[email protected] | b43c97c | 2008-10-22 19:50:58 | [diff] [blame] | 342 | EXPECT_TRUE(sock->IsConnected()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 343 | |
[email protected] | e3eb8f8 | 2010-09-21 15:25:15 | [diff] [blame] | 344 | const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 345 | scoped_refptr<net::IOBuffer> request_buffer( |
| 346 | new net::IOBuffer(arraysize(request_text) - 1)); |
[email protected] | e3eb8f8 | 2010-09-21 15:25:15 | [diff] [blame] | 347 | memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
[email protected] | ffeb088 | 2009-04-30 21:51:25 | [diff] [blame] | 348 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 349 | rv = sock->Write(request_buffer, arraysize(request_text) - 1, |
| 350 | callback.callback()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 351 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 352 | |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 353 | if (rv == net::ERR_IO_PENDING) |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 354 | rv = callback.WaitForResult(); |
[email protected] | e3eb8f8 | 2010-09-21 15:25:15 | [diff] [blame] | 355 | EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 356 | |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 357 | scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 358 | for (;;) { |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 359 | rv = sock->Read(buf, 4096, callback.callback()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 360 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 361 | |
| 362 | if (rv == net::ERR_IO_PENDING) |
| 363 | rv = callback.WaitForResult(); |
| 364 | |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 365 | EXPECT_GE(rv, 0); |
| 366 | if (rv <= 0) |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 367 | break; |
| 368 | } |
| 369 | } |
| 370 | |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 371 | // Test the full duplex mode, with Read and Write pending at the same time. |
| 372 | // This test also serves as a regression test for http://crbug.com/29815. |
| 373 | TEST_F(SSLClientSocketTest, Read_FullDuplex) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 374 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 375 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 376 | |
| 377 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 378 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 379 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 380 | net::TestCompletionCallback callback; // Used for everything except Write. |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 381 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 382 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 383 | addr, NULL, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 384 | int rv = transport->Connect(callback.callback()); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 385 | if (rv == net::ERR_IO_PENDING) |
| 386 | rv = callback.WaitForResult(); |
| 387 | EXPECT_EQ(net::OK, rv); |
| 388 | |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 389 | net::SSLClientSocketContext context; |
| 390 | context.cert_verifier = cert_verifier_.get(); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 391 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 392 | socket_factory_->CreateSSLClientSocket( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 393 | transport, test_server.host_port_pair(), kDefaultSSLConfig, |
[email protected] | feb79bcd | 2011-07-21 16:55:17 | [diff] [blame] | 394 | NULL, context)); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 395 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 396 | rv = sock->Connect(callback.callback()); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 397 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 398 | rv = callback.WaitForResult(); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 399 | EXPECT_EQ(net::OK, rv); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 400 | EXPECT_TRUE(sock->IsConnected()); |
| 401 | |
| 402 | // Issue a "hanging" Read first. |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 403 | scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 404 | rv = sock->Read(buf, 4096, callback.callback()); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 405 | // We haven't written the request, so there should be no response yet. |
| 406 | ASSERT_EQ(net::ERR_IO_PENDING, rv); |
| 407 | |
| 408 | // Write the request. |
| 409 | // The request is padded with a User-Agent header to a size that causes the |
| 410 | // memio circular buffer (4k bytes) in SSLClientSocketNSS to wrap around. |
| 411 | // This tests the fix for http://crbug.com/29815. |
| 412 | std::string request_text = "GET / HTTP/1.1\r\nUser-Agent: long browser name "; |
[email protected] | 73343a3 | 2011-08-18 02:32:16 | [diff] [blame] | 413 | for (int i = 0; i < 3770; ++i) |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 414 | request_text.push_back('*'); |
| 415 | request_text.append("\r\n\r\n"); |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 416 | scoped_refptr<net::IOBuffer> request_buffer( |
| 417 | new net::StringIOBuffer(request_text)); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 418 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 419 | net::TestCompletionCallback callback2; // Used for Write only. |
| 420 | rv = sock->Write(request_buffer, request_text.size(), callback2.callback()); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 421 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 422 | |
| 423 | if (rv == net::ERR_IO_PENDING) |
| 424 | rv = callback2.WaitForResult(); |
| 425 | EXPECT_EQ(static_cast<int>(request_text.size()), rv); |
| 426 | |
| 427 | // Now get the Read result. |
| 428 | rv = callback.WaitForResult(); |
| 429 | EXPECT_GT(rv, 0); |
| 430 | } |
| 431 | |
[email protected] | 010e27e | 2009-08-27 17:49:41 | [diff] [blame] | 432 | TEST_F(SSLClientSocketTest, Read_SmallChunks) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 433 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 434 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 435 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 436 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 437 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 438 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 439 | net::TestCompletionCallback callback; |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 440 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 441 | addr, NULL, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 442 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 443 | if (rv == net::ERR_IO_PENDING) |
| 444 | rv = callback.WaitForResult(); |
| 445 | EXPECT_EQ(net::OK, rv); |
| 446 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 447 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 448 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 449 | kDefaultSSLConfig)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 450 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 451 | rv = sock->Connect(callback.callback()); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 452 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 453 | rv = callback.WaitForResult(); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 454 | EXPECT_EQ(net::OK, rv); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 455 | |
| 456 | const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 457 | scoped_refptr<net::IOBuffer> request_buffer( |
| 458 | new net::IOBuffer(arraysize(request_text) - 1)); |
[email protected] | ffeb088 | 2009-04-30 21:51:25 | [diff] [blame] | 459 | memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
| 460 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 461 | rv = sock->Write(request_buffer, arraysize(request_text) - 1, |
| 462 | callback.callback()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 463 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 464 | |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 465 | if (rv == net::ERR_IO_PENDING) |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 466 | rv = callback.WaitForResult(); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 467 | EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 468 | |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 469 | scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(1)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 470 | for (;;) { |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 471 | rv = sock->Read(buf, 1, callback.callback()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 472 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 473 | |
| 474 | if (rv == net::ERR_IO_PENDING) |
| 475 | rv = callback.WaitForResult(); |
| 476 | |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 477 | EXPECT_GE(rv, 0); |
| 478 | if (rv <= 0) |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 479 | break; |
| 480 | } |
| 481 | } |
| 482 | |
[email protected] | 010e27e | 2009-08-27 17:49:41 | [diff] [blame] | 483 | TEST_F(SSLClientSocketTest, Read_Interrupted) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 484 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 485 | ASSERT_TRUE(test_server.Start()); |
[email protected] | 73e0bba | 2009-02-19 22:57:09 | [diff] [blame] | 486 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 487 | net::AddressList addr; |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 488 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 489 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 490 | net::TestCompletionCallback callback; |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 491 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 0a0b768 | 2010-08-25 17:08:07 | [diff] [blame] | 492 | addr, NULL, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 493 | int rv = transport->Connect(callback.callback()); |
[email protected] | bacff65 | 2009-03-31 17:50:33 | [diff] [blame] | 494 | if (rv == net::ERR_IO_PENDING) |
| 495 | rv = callback.WaitForResult(); |
| 496 | EXPECT_EQ(net::OK, rv); |
| 497 | |
[email protected] | aaead50 | 2008-10-15 00:20:11 | [diff] [blame] | 498 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 499 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 500 | kDefaultSSLConfig)); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 501 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 502 | rv = sock->Connect(callback.callback()); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 503 | if (rv == net::ERR_IO_PENDING) |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 504 | rv = callback.WaitForResult(); |
[email protected] | 6526380c | 2010-11-10 04:40:33 | [diff] [blame] | 505 | EXPECT_EQ(net::OK, rv); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 506 | |
| 507 | const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 508 | scoped_refptr<net::IOBuffer> request_buffer( |
| 509 | new net::IOBuffer(arraysize(request_text) - 1)); |
[email protected] | ffeb088 | 2009-04-30 21:51:25 | [diff] [blame] | 510 | memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
| 511 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 512 | rv = sock->Write(request_buffer, arraysize(request_text) - 1, |
| 513 | callback.callback()); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 514 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 515 | |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 516 | if (rv == net::ERR_IO_PENDING) |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 517 | rv = callback.WaitForResult(); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 518 | EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 519 | |
| 520 | // Do a partial read and then exit. This test should not crash! |
[email protected] | ad8e04a | 2010-11-01 04:16:27 | [diff] [blame] | 521 | scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(512)); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 522 | rv = sock->Read(buf, 512, callback.callback()); |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 523 | EXPECT_TRUE(rv > 0 || rv == net::ERR_IO_PENDING); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 524 | |
| 525 | if (rv == net::ERR_IO_PENDING) |
| 526 | rv = callback.WaitForResult(); |
| 527 | |
[email protected] | 914286d6 | 2009-12-10 23:06:44 | [diff] [blame] | 528 | EXPECT_GT(rv, 0); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 529 | } |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 530 | |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 531 | TEST_F(SSLClientSocketTest, Read_FullLogging) { |
| 532 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 533 | ASSERT_TRUE(test_server.Start()); |
| 534 | |
| 535 | net::AddressList addr; |
| 536 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 537 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 538 | net::TestCompletionCallback callback; |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 539 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
| 540 | log.SetLogLevel(net::NetLog::LOG_ALL); |
| 541 | net::StreamSocket* transport = new net::TCPClientSocket( |
| 542 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 543 | int rv = transport->Connect(callback.callback()); |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 544 | if (rv == net::ERR_IO_PENDING) |
| 545 | rv = callback.WaitForResult(); |
| 546 | EXPECT_EQ(net::OK, rv); |
| 547 | |
| 548 | scoped_ptr<net::SSLClientSocket> sock( |
| 549 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 550 | kDefaultSSLConfig)); |
| 551 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 552 | rv = sock->Connect(callback.callback()); |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 553 | if (rv == net::ERR_IO_PENDING) |
| 554 | rv = callback.WaitForResult(); |
| 555 | EXPECT_EQ(net::OK, rv); |
| 556 | EXPECT_TRUE(sock->IsConnected()); |
| 557 | |
| 558 | const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
| 559 | scoped_refptr<net::IOBuffer> request_buffer( |
| 560 | new net::IOBuffer(arraysize(request_text) - 1)); |
| 561 | memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
| 562 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 563 | rv = sock->Write(request_buffer, arraysize(request_text) - 1, |
| 564 | callback.callback()); |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 565 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 566 | |
| 567 | if (rv == net::ERR_IO_PENDING) |
| 568 | rv = callback.WaitForResult(); |
| 569 | EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv); |
| 570 | |
| 571 | net::CapturingNetLog::EntryList entries; |
| 572 | log.GetEntries(&entries); |
| 573 | size_t last_index = net::ExpectLogContainsSomewhereAfter( |
| 574 | entries, 5, net::NetLog::TYPE_SSL_SOCKET_BYTES_SENT, |
| 575 | net::NetLog::PHASE_NONE); |
| 576 | |
| 577 | scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); |
| 578 | for (;;) { |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 579 | rv = sock->Read(buf, 4096, callback.callback()); |
[email protected] | 1d872d3 | 2011-05-19 02:45:33 | [diff] [blame] | 580 | EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
| 581 | |
| 582 | if (rv == net::ERR_IO_PENDING) |
| 583 | rv = callback.WaitForResult(); |
| 584 | |
| 585 | EXPECT_GE(rv, 0); |
| 586 | if (rv <= 0) |
| 587 | break; |
| 588 | |
| 589 | log.GetEntries(&entries); |
| 590 | last_index = net::ExpectLogContainsSomewhereAfter( |
| 591 | entries, last_index + 1, net::NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, |
| 592 | net::NetLog::PHASE_NONE); |
| 593 | } |
| 594 | } |
| 595 | |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 596 | // Regression test for http://crbug.com/42538 |
| 597 | TEST_F(SSLClientSocketTest, PrematureApplicationData) { |
[email protected] | 95409e1 | 2010-08-17 20:07:11 | [diff] [blame] | 598 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 599 | ASSERT_TRUE(test_server.Start()); |
| 600 | |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 601 | net::AddressList addr; |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 602 | net::TestCompletionCallback callback; |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 603 | |
| 604 | static const unsigned char application_data[] = { |
| 605 | 0x17, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x46, 0x03, 0x01, 0x4b, |
| 606 | 0xc2, 0xf8, 0xb2, 0xc1, 0x56, 0x42, 0xb9, 0x57, 0x7f, 0xde, 0x87, 0x46, |
| 607 | 0xf7, 0xa3, 0x52, 0x42, 0x21, 0xf0, 0x13, 0x1c, 0x9c, 0x83, 0x88, 0xd6, |
| 608 | 0x93, 0x0c, 0xf6, 0x36, 0x30, 0x05, 0x7e, 0x20, 0xb5, 0xb5, 0x73, 0x36, |
| 609 | 0x53, 0x83, 0x0a, 0xfc, 0x17, 0x63, 0xbf, 0xa0, 0xe4, 0x42, 0x90, 0x0d, |
| 610 | 0x2f, 0x18, 0x6d, 0x20, 0xd8, 0x36, 0x3f, 0xfc, 0xe6, 0x01, 0xfa, 0x0f, |
| 611 | 0xa5, 0x75, 0x7f, 0x09, 0x00, 0x04, 0x00, 0x16, 0x03, 0x01, 0x11, 0x57, |
| 612 | 0x0b, 0x00, 0x11, 0x53, 0x00, 0x11, 0x50, 0x00, 0x06, 0x22, 0x30, 0x82, |
| 613 | 0x06, 0x1e, 0x30, 0x82, 0x05, 0x06, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, |
| 614 | 0x0a |
| 615 | }; |
| 616 | |
| 617 | // All reads and writes complete synchronously (async=false). |
| 618 | net::MockRead data_reads[] = { |
| 619 | net::MockRead(false, reinterpret_cast<const char*>(application_data), |
| 620 | arraysize(application_data)), |
| 621 | net::MockRead(false, net::OK), |
| 622 | }; |
| 623 | |
| 624 | net::StaticSocketDataProvider data(data_reads, arraysize(data_reads), |
| 625 | NULL, 0); |
| 626 | |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 627 | net::StreamSocket* transport = |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 628 | new net::MockTCPClientSocket(addr, NULL, &data); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 629 | int rv = transport->Connect(callback.callback()); |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 630 | if (rv == net::ERR_IO_PENDING) |
| 631 | rv = callback.WaitForResult(); |
| 632 | EXPECT_EQ(net::OK, rv); |
| 633 | |
| 634 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 635 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 636 | kDefaultSSLConfig)); |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 637 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 638 | rv = sock->Connect(callback.callback()); |
[email protected] | 39afe64 | 2010-04-29 14:55:18 | [diff] [blame] | 639 | EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); |
| 640 | } |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 641 | |
[email protected] | 109805a | 2010-12-07 18:17:06 | [diff] [blame] | 642 | // TODO(rsleevi): Not implemented for Schannel. As Schannel is only used when |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 643 | // performing client authentication, it will not be tested here. |
[email protected] | 7deea3d | 2011-01-09 06:03:41 | [diff] [blame] | 644 | TEST_F(SSLClientSocketTest, CipherSuiteDisables) { |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 645 | // Rather than exhaustively disabling every RC4 ciphersuite defined at |
| 646 | // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, |
| 647 | // only disabling those cipher suites that the test server actually |
| 648 | // implements. |
| 649 | const uint16 kCiphersToDisable[] = { |
| 650 | 0x0005, // TLS_RSA_WITH_RC4_128_SHA |
| 651 | }; |
| 652 | |
| 653 | net::TestServer::HTTPSOptions https_options; |
| 654 | // Enable only RC4 on the test server. |
| 655 | https_options.bulk_ciphers = |
| 656 | net::TestServer::HTTPSOptions::BULK_CIPHER_RC4; |
| 657 | net::TestServer test_server(https_options, FilePath()); |
| 658 | ASSERT_TRUE(test_server.Start()); |
| 659 | |
| 660 | net::AddressList addr; |
| 661 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 662 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 663 | net::TestCompletionCallback callback; |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 664 | net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
[email protected] | 3268023f | 2011-05-05 00:08:10 | [diff] [blame] | 665 | net::StreamSocket* transport = new net::TCPClientSocket( |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 666 | addr, &log, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 667 | int rv = transport->Connect(callback.callback()); |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 668 | if (rv == net::ERR_IO_PENDING) |
| 669 | rv = callback.WaitForResult(); |
| 670 | EXPECT_EQ(net::OK, rv); |
| 671 | |
| 672 | net::SSLConfig ssl_config; |
| 673 | for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) |
| 674 | ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); |
| 675 | |
| 676 | scoped_ptr<net::SSLClientSocket> sock( |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 677 | CreateSSLClientSocket(transport, test_server.host_port_pair(), |
| 678 | ssl_config)); |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 679 | |
| 680 | EXPECT_FALSE(sock->IsConnected()); |
| 681 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 682 | rv = sock->Connect(callback.callback()); |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 683 | net::CapturingNetLog::EntryList entries; |
| 684 | log.GetEntries(&entries); |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 685 | EXPECT_TRUE(net::LogContainsBeginEvent( |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 686 | entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 687 | |
| 688 | // NSS has special handling that maps a handshake_failure alert received |
| 689 | // immediately after a client_hello to be a mismatched cipher suite error, |
| 690 | // leading to ERR_SSL_VERSION_OR_CIPHER_MISMATCH. When using OpenSSL or |
| 691 | // Secure Transport (OS X), the handshake_failure is bubbled up without any |
| 692 | // interpretation, leading to ERR_SSL_PROTOCOL_ERROR. Either way, a failure |
| 693 | // indicates that no cipher suite was negotiated with the test server. |
| 694 | if (rv == net::ERR_IO_PENDING) |
| 695 | rv = callback.WaitForResult(); |
| 696 | EXPECT_TRUE(rv == net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH || |
| 697 | rv == net::ERR_SSL_PROTOCOL_ERROR); |
| 698 | // The exact ordering differs between SSLClientSocketNSS (which issues an |
| 699 | // extra read) and SSLClientSocketMac (which does not). Just make sure the |
| 700 | // error appears somewhere in the log. |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 701 | log.GetEntries(&entries); |
| 702 | net::ExpectLogContainsSomewhere(entries, 0, |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 703 | net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| 704 | net::NetLog::PHASE_NONE); |
| 705 | |
| 706 | // We cannot test sock->IsConnected(), as the NSS implementation disconnects |
| 707 | // the socket when it encounters an error, whereas other implementations |
| 708 | // leave it connected. |
[email protected] | 7deea3d | 2011-01-09 06:03:41 | [diff] [blame] | 709 | // Because this an error that the test server is mutually aware of, as opposed |
| 710 | // to being an error such as a certificate name mismatch, which is |
| 711 | // client-only, the exact index of the SSL connect end depends on how |
| 712 | // quickly the test server closes the underlying socket. If the test server |
| 713 | // closes before the IO message loop pumps messages, there may be a 0-byte |
| 714 | // Read event in the NetLog due to TCPClientSocket picking up the EOF. As a |
| 715 | // result, the SSL connect end event will be the second-to-last entry, |
| 716 | // rather than the last entry. |
| 717 | EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1) || |
| 718 | LogContainsSSLConnectEndEvent(entries, -2)); |
[email protected] | 47f7d74 | 2010-11-11 04:12:53 | [diff] [blame] | 719 | } |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 720 | |
| 721 | // When creating an SSLClientSocket, it is allowed to pass in a |
| 722 | // ClientSocketHandle that is not obtained from a client socket pool. |
| 723 | // Here we verify that such a simple ClientSocketHandle, not associated with any |
| 724 | // client socket pool, can be destroyed safely. |
| 725 | TEST_F(SSLClientSocketTest, ClientSocketHandleNotFromPool) { |
| 726 | net::TestServer test_server(net::TestServer::TYPE_HTTPS, FilePath()); |
| 727 | ASSERT_TRUE(test_server.Start()); |
| 728 | |
| 729 | net::AddressList addr; |
| 730 | ASSERT_TRUE(test_server.GetAddressList(&addr)); |
| 731 | |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 732 | net::TestCompletionCallback callback; |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 733 | net::StreamSocket* transport = new net::TCPClientSocket( |
| 734 | addr, NULL, net::NetLog::Source()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 735 | int rv = transport->Connect(callback.callback()); |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 736 | if (rv == net::ERR_IO_PENDING) |
| 737 | rv = callback.WaitForResult(); |
| 738 | EXPECT_EQ(net::OK, rv); |
| 739 | |
| 740 | net::ClientSocketHandle* socket_handle = new net::ClientSocketHandle(); |
| 741 | socket_handle->set_socket(transport); |
| 742 | |
| 743 | net::SSLClientSocketContext context; |
| 744 | context.cert_verifier = cert_verifier_.get(); |
| 745 | scoped_ptr<net::SSLClientSocket> ssl_socket( |
| 746 | socket_factory_->CreateSSLClientSocket( |
| 747 | socket_handle, test_server.host_port_pair(), kDefaultSSLConfig, |
| 748 | NULL, context)); |
| 749 | |
| 750 | EXPECT_FALSE(ssl_socket->IsConnected()); |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 751 | rv = ssl_socket->Connect(callback.callback()); |
[email protected] | b442da3 | 2011-08-16 19:32:28 | [diff] [blame] | 752 | if (rv == net::ERR_IO_PENDING) |
| 753 | rv = callback.WaitForResult(); |
| 754 | EXPECT_EQ(net::OK, rv); |
| 755 | } |
[email protected] | c3456bb | 2011-12-12 22:22:19 | [diff] [blame] | 756 | |
| 757 | // Verifies that SSLClientSocket::ClearSessionCache can be called without |
| 758 | // explicit NSS initialization. |
| 759 | TEST(SSLClientSocket, ClearSessionCache) { |
| 760 | net::SSLClientSocket::ClearSessionCache(); |
| 761 | } |