OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "net/base/address_list.h" | 7 #include "net/base/address_list.h" |
| 8 #include "net/base/cert_verifier.h" |
8 #include "net/base/host_resolver.h" | 9 #include "net/base/host_resolver.h" |
9 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
10 #include "net/base/net_log.h" | 11 #include "net/base/net_log.h" |
11 #include "net/base/net_log_unittest.h" | 12 #include "net/base/net_log_unittest.h" |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "net/base/ssl_config_service.h" | 14 #include "net/base/ssl_config_service.h" |
14 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
15 #include "net/socket/client_socket_factory.h" | 16 #include "net/socket/client_socket_factory.h" |
16 #include "net/socket/socket_test_util.h" | 17 #include "net/socket/socket_test_util.h" |
17 #include "net/socket/tcp_client_socket.h" | 18 #include "net/socket/tcp_client_socket.h" |
18 #include "net/test/test_server.h" | 19 #include "net/test/test_server.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
21 | 22 |
22 //----------------------------------------------------------------------------- | 23 //----------------------------------------------------------------------------- |
23 | 24 |
24 const net::SSLConfig kDefaultSSLConfig; | 25 const net::SSLConfig kDefaultSSLConfig; |
25 | 26 |
26 class SSLClientSocketTest : public PlatformTest { | 27 class SSLClientSocketTest : public PlatformTest { |
27 public: | 28 public: |
28 SSLClientSocketTest() | 29 SSLClientSocketTest() |
29 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) { | 30 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()), |
| 31 cert_verifier_(new net::CertVerifier) { |
30 } | 32 } |
31 | 33 |
32 protected: | 34 protected: |
| 35 net::SSLClientSocket* CreateSSLClientSocket( |
| 36 net::ClientSocket* transport_socket, |
| 37 const net::HostPortPair& host_and_port, |
| 38 const net::SSLConfig& ssl_config) { |
| 39 return socket_factory_->CreateSSLClientSocket(transport_socket, |
| 40 host_and_port, |
| 41 ssl_config, |
| 42 NULL, |
| 43 cert_verifier_.get()); |
| 44 } |
| 45 |
33 net::ClientSocketFactory* socket_factory_; | 46 net::ClientSocketFactory* socket_factory_; |
| 47 scoped_ptr<net::CertVerifier> cert_verifier_; |
34 }; | 48 }; |
35 | 49 |
36 //----------------------------------------------------------------------------- | 50 //----------------------------------------------------------------------------- |
37 | 51 |
38 // LogContainsSSLConnectEndEvent returns true if the given index in the given | 52 // LogContainsSSLConnectEndEvent returns true if the given index in the given |
39 // log is an SSL connect end event. The NSS sockets will cork in an attempt to | 53 // log is an SSL connect end event. The NSS sockets will cork in an attempt to |
40 // merge the first application data record with the Finished message when false | 54 // merge the first application data record with the Finished message when false |
41 // starting. However, in order to avoid the server timing out the handshake, | 55 // starting. However, in order to avoid the server timing out the handshake, |
42 // they'll give up waiting for application data and send the Finished after a | 56 // they'll give up waiting for application data and send the Finished after a |
43 // timeout. This means that an SSL connect end event may appear as a socket | 57 // timeout. This means that an SSL connect end event may appear as a socket |
(...skipping 16 matching lines...) Expand all Loading... |
60 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 74 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
61 net::ClientSocket* transport = new net::TCPClientSocket( | 75 net::ClientSocket* transport = new net::TCPClientSocket( |
62 addr, &log, net::NetLog::Source()); | 76 addr, &log, net::NetLog::Source()); |
63 int rv = transport->Connect(&callback); | 77 int rv = transport->Connect(&callback); |
64 if (rv == net::ERR_IO_PENDING) | 78 if (rv == net::ERR_IO_PENDING) |
65 rv = callback.WaitForResult(); | 79 rv = callback.WaitForResult(); |
66 EXPECT_EQ(net::OK, rv); | 80 EXPECT_EQ(net::OK, rv); |
67 | 81 |
68 scoped_ptr<net::SSLClientSocket> sock( | 82 scoped_ptr<net::SSLClientSocket> sock( |
69 socket_factory_->CreateSSLClientSocket( | 83 socket_factory_->CreateSSLClientSocket( |
70 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 84 transport, test_server.host_port_pair(), kDefaultSSLConfig, |
| 85 NULL, cert_verifier_.get())); |
71 | 86 |
72 EXPECT_FALSE(sock->IsConnected()); | 87 EXPECT_FALSE(sock->IsConnected()); |
73 | 88 |
74 rv = sock->Connect(&callback); | 89 rv = sock->Connect(&callback); |
75 | 90 |
76 net::CapturingNetLog::EntryList entries; | 91 net::CapturingNetLog::EntryList entries; |
77 log.GetEntries(&entries); | 92 log.GetEntries(&entries); |
78 EXPECT_TRUE(net::LogContainsBeginEvent( | 93 EXPECT_TRUE(net::LogContainsBeginEvent( |
79 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); | 94 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
80 if (rv == net::ERR_IO_PENDING) | 95 if (rv == net::ERR_IO_PENDING) |
(...skipping 19 matching lines...) Expand all Loading... |
100 TestCompletionCallback callback; | 115 TestCompletionCallback callback; |
101 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 116 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
102 net::ClientSocket* transport = new net::TCPClientSocket( | 117 net::ClientSocket* transport = new net::TCPClientSocket( |
103 addr, &log, net::NetLog::Source()); | 118 addr, &log, net::NetLog::Source()); |
104 int rv = transport->Connect(&callback); | 119 int rv = transport->Connect(&callback); |
105 if (rv == net::ERR_IO_PENDING) | 120 if (rv == net::ERR_IO_PENDING) |
106 rv = callback.WaitForResult(); | 121 rv = callback.WaitForResult(); |
107 EXPECT_EQ(net::OK, rv); | 122 EXPECT_EQ(net::OK, rv); |
108 | 123 |
109 scoped_ptr<net::SSLClientSocket> sock( | 124 scoped_ptr<net::SSLClientSocket> sock( |
110 socket_factory_->CreateSSLClientSocket( | 125 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
111 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 126 kDefaultSSLConfig)); |
112 | 127 |
113 EXPECT_FALSE(sock->IsConnected()); | 128 EXPECT_FALSE(sock->IsConnected()); |
114 | 129 |
115 rv = sock->Connect(&callback); | 130 rv = sock->Connect(&callback); |
116 | 131 |
117 net::CapturingNetLog::EntryList entries; | 132 net::CapturingNetLog::EntryList entries; |
118 log.GetEntries(&entries); | 133 log.GetEntries(&entries); |
119 EXPECT_TRUE(net::LogContainsBeginEvent( | 134 EXPECT_TRUE(net::LogContainsBeginEvent( |
120 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); | 135 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
121 if (rv == net::ERR_IO_PENDING) | 136 if (rv == net::ERR_IO_PENDING) |
(...skipping 21 matching lines...) Expand all Loading... |
143 TestCompletionCallback callback; | 158 TestCompletionCallback callback; |
144 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 159 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
145 net::ClientSocket* transport = new net::TCPClientSocket( | 160 net::ClientSocket* transport = new net::TCPClientSocket( |
146 addr, &log, net::NetLog::Source()); | 161 addr, &log, net::NetLog::Source()); |
147 int rv = transport->Connect(&callback); | 162 int rv = transport->Connect(&callback); |
148 if (rv == net::ERR_IO_PENDING) | 163 if (rv == net::ERR_IO_PENDING) |
149 rv = callback.WaitForResult(); | 164 rv = callback.WaitForResult(); |
150 EXPECT_EQ(net::OK, rv); | 165 EXPECT_EQ(net::OK, rv); |
151 | 166 |
152 scoped_ptr<net::SSLClientSocket> sock( | 167 scoped_ptr<net::SSLClientSocket> sock( |
153 socket_factory_->CreateSSLClientSocket( | 168 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
154 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 169 kDefaultSSLConfig)); |
155 | 170 |
156 EXPECT_FALSE(sock->IsConnected()); | 171 EXPECT_FALSE(sock->IsConnected()); |
157 | 172 |
158 rv = sock->Connect(&callback); | 173 rv = sock->Connect(&callback); |
159 | 174 |
160 net::CapturingNetLog::EntryList entries; | 175 net::CapturingNetLog::EntryList entries; |
161 log.GetEntries(&entries); | 176 log.GetEntries(&entries); |
162 EXPECT_TRUE(net::LogContainsBeginEvent( | 177 EXPECT_TRUE(net::LogContainsBeginEvent( |
163 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); | 178 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
164 if (rv == net::ERR_IO_PENDING) | 179 if (rv == net::ERR_IO_PENDING) |
(...skipping 24 matching lines...) Expand all Loading... |
189 TestCompletionCallback callback; | 204 TestCompletionCallback callback; |
190 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); | 205 net::CapturingNetLog log(net::CapturingNetLog::kUnbounded); |
191 net::ClientSocket* transport = new net::TCPClientSocket( | 206 net::ClientSocket* transport = new net::TCPClientSocket( |
192 addr, &log, net::NetLog::Source()); | 207 addr, &log, net::NetLog::Source()); |
193 int rv = transport->Connect(&callback); | 208 int rv = transport->Connect(&callback); |
194 if (rv == net::ERR_IO_PENDING) | 209 if (rv == net::ERR_IO_PENDING) |
195 rv = callback.WaitForResult(); | 210 rv = callback.WaitForResult(); |
196 EXPECT_EQ(net::OK, rv); | 211 EXPECT_EQ(net::OK, rv); |
197 | 212 |
198 scoped_ptr<net::SSLClientSocket> sock( | 213 scoped_ptr<net::SSLClientSocket> sock( |
199 socket_factory_->CreateSSLClientSocket( | 214 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
200 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 215 kDefaultSSLConfig)); |
201 | 216 |
202 EXPECT_FALSE(sock->IsConnected()); | 217 EXPECT_FALSE(sock->IsConnected()); |
203 | 218 |
204 rv = sock->Connect(&callback); | 219 rv = sock->Connect(&callback); |
205 | 220 |
206 net::CapturingNetLog::EntryList entries; | 221 net::CapturingNetLog::EntryList entries; |
207 log.GetEntries(&entries); | 222 log.GetEntries(&entries); |
208 EXPECT_TRUE(net::LogContainsBeginEvent( | 223 EXPECT_TRUE(net::LogContainsBeginEvent( |
209 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); | 224 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
210 if (rv == net::ERR_IO_PENDING) | 225 if (rv == net::ERR_IO_PENDING) |
(...skipping 25 matching lines...) Expand all Loading... |
236 int rv = transport->Connect(&callback); | 251 int rv = transport->Connect(&callback); |
237 if (rv == net::ERR_IO_PENDING) | 252 if (rv == net::ERR_IO_PENDING) |
238 rv = callback.WaitForResult(); | 253 rv = callback.WaitForResult(); |
239 EXPECT_EQ(net::OK, rv); | 254 EXPECT_EQ(net::OK, rv); |
240 | 255 |
241 net::SSLConfig ssl_config = kDefaultSSLConfig; | 256 net::SSLConfig ssl_config = kDefaultSSLConfig; |
242 ssl_config.send_client_cert = true; | 257 ssl_config.send_client_cert = true; |
243 ssl_config.client_cert = NULL; | 258 ssl_config.client_cert = NULL; |
244 | 259 |
245 scoped_ptr<net::SSLClientSocket> sock( | 260 scoped_ptr<net::SSLClientSocket> sock( |
246 socket_factory_->CreateSSLClientSocket( | 261 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
247 transport, test_server.host_port_pair(), ssl_config, NULL)); | 262 ssl_config)); |
248 | 263 |
249 EXPECT_FALSE(sock->IsConnected()); | 264 EXPECT_FALSE(sock->IsConnected()); |
250 | 265 |
251 // Our test server accepts certificate-less connections. | 266 // Our test server accepts certificate-less connections. |
252 // TODO(davidben): Add a test which requires them and verify the error. | 267 // TODO(davidben): Add a test which requires them and verify the error. |
253 rv = sock->Connect(&callback); | 268 rv = sock->Connect(&callback); |
254 | 269 |
255 net::CapturingNetLog::EntryList entries; | 270 net::CapturingNetLog::EntryList entries; |
256 log.GetEntries(&entries); | 271 log.GetEntries(&entries); |
257 EXPECT_TRUE(net::LogContainsBeginEvent( | 272 EXPECT_TRUE(net::LogContainsBeginEvent( |
(...skipping 24 matching lines...) Expand all Loading... |
282 | 297 |
283 TestCompletionCallback callback; | 298 TestCompletionCallback callback; |
284 net::ClientSocket* transport = new net::TCPClientSocket( | 299 net::ClientSocket* transport = new net::TCPClientSocket( |
285 addr, NULL, net::NetLog::Source()); | 300 addr, NULL, net::NetLog::Source()); |
286 int rv = transport->Connect(&callback); | 301 int rv = transport->Connect(&callback); |
287 if (rv == net::ERR_IO_PENDING) | 302 if (rv == net::ERR_IO_PENDING) |
288 rv = callback.WaitForResult(); | 303 rv = callback.WaitForResult(); |
289 EXPECT_EQ(net::OK, rv); | 304 EXPECT_EQ(net::OK, rv); |
290 | 305 |
291 scoped_ptr<net::SSLClientSocket> sock( | 306 scoped_ptr<net::SSLClientSocket> sock( |
292 socket_factory_->CreateSSLClientSocket( | 307 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
293 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 308 kDefaultSSLConfig)); |
294 | 309 |
295 rv = sock->Connect(&callback); | 310 rv = sock->Connect(&callback); |
296 if (rv == net::ERR_IO_PENDING) | 311 if (rv == net::ERR_IO_PENDING) |
297 rv = callback.WaitForResult(); | 312 rv = callback.WaitForResult(); |
298 EXPECT_EQ(net::OK, rv); | 313 EXPECT_EQ(net::OK, rv); |
299 EXPECT_TRUE(sock->IsConnected()); | 314 EXPECT_TRUE(sock->IsConnected()); |
300 | 315 |
301 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 316 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
302 scoped_refptr<net::IOBuffer> request_buffer( | 317 scoped_refptr<net::IOBuffer> request_buffer( |
303 new net::IOBuffer(arraysize(request_text) - 1)); | 318 new net::IOBuffer(arraysize(request_text) - 1)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 353 |
339 net::ClientSocket* transport = new net::TCPClientSocket( | 354 net::ClientSocket* transport = new net::TCPClientSocket( |
340 addr, NULL, net::NetLog::Source()); | 355 addr, NULL, net::NetLog::Source()); |
341 int rv = transport->Connect(&callback); | 356 int rv = transport->Connect(&callback); |
342 if (rv == net::ERR_IO_PENDING) | 357 if (rv == net::ERR_IO_PENDING) |
343 rv = callback.WaitForResult(); | 358 rv = callback.WaitForResult(); |
344 EXPECT_EQ(net::OK, rv); | 359 EXPECT_EQ(net::OK, rv); |
345 | 360 |
346 scoped_ptr<net::SSLClientSocket> sock( | 361 scoped_ptr<net::SSLClientSocket> sock( |
347 socket_factory_->CreateSSLClientSocket( | 362 socket_factory_->CreateSSLClientSocket( |
348 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 363 transport, test_server.host_port_pair(), kDefaultSSLConfig, |
| 364 NULL, cert_verifier_.get())); |
349 | 365 |
350 rv = sock->Connect(&callback); | 366 rv = sock->Connect(&callback); |
351 if (rv == net::ERR_IO_PENDING) | 367 if (rv == net::ERR_IO_PENDING) |
352 rv = callback.WaitForResult(); | 368 rv = callback.WaitForResult(); |
353 EXPECT_EQ(net::OK, rv); | 369 EXPECT_EQ(net::OK, rv); |
354 EXPECT_TRUE(sock->IsConnected()); | 370 EXPECT_TRUE(sock->IsConnected()); |
355 | 371 |
356 // Issue a "hanging" Read first. | 372 // Issue a "hanging" Read first. |
357 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); | 373 scoped_refptr<net::IOBuffer> buf(new net::IOBuffer(4096)); |
358 rv = sock->Read(buf, 4096, &callback); | 374 rv = sock->Read(buf, 4096, &callback); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 407 |
392 TestCompletionCallback callback; | 408 TestCompletionCallback callback; |
393 net::ClientSocket* transport = new net::TCPClientSocket( | 409 net::ClientSocket* transport = new net::TCPClientSocket( |
394 addr, NULL, net::NetLog::Source()); | 410 addr, NULL, net::NetLog::Source()); |
395 int rv = transport->Connect(&callback); | 411 int rv = transport->Connect(&callback); |
396 if (rv == net::ERR_IO_PENDING) | 412 if (rv == net::ERR_IO_PENDING) |
397 rv = callback.WaitForResult(); | 413 rv = callback.WaitForResult(); |
398 EXPECT_EQ(net::OK, rv); | 414 EXPECT_EQ(net::OK, rv); |
399 | 415 |
400 scoped_ptr<net::SSLClientSocket> sock( | 416 scoped_ptr<net::SSLClientSocket> sock( |
401 socket_factory_->CreateSSLClientSocket( | 417 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
402 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 418 kDefaultSSLConfig)); |
403 | 419 |
404 rv = sock->Connect(&callback); | 420 rv = sock->Connect(&callback); |
405 if (rv == net::ERR_IO_PENDING) | 421 if (rv == net::ERR_IO_PENDING) |
406 rv = callback.WaitForResult(); | 422 rv = callback.WaitForResult(); |
407 EXPECT_EQ(net::OK, rv); | 423 EXPECT_EQ(net::OK, rv); |
408 | 424 |
409 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 425 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
410 scoped_refptr<net::IOBuffer> request_buffer( | 426 scoped_refptr<net::IOBuffer> request_buffer( |
411 new net::IOBuffer(arraysize(request_text) - 1)); | 427 new net::IOBuffer(arraysize(request_text) - 1)); |
412 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 428 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
(...skipping 28 matching lines...) Expand all Loading... |
441 | 457 |
442 TestCompletionCallback callback; | 458 TestCompletionCallback callback; |
443 net::ClientSocket* transport = new net::TCPClientSocket( | 459 net::ClientSocket* transport = new net::TCPClientSocket( |
444 addr, NULL, net::NetLog::Source()); | 460 addr, NULL, net::NetLog::Source()); |
445 int rv = transport->Connect(&callback); | 461 int rv = transport->Connect(&callback); |
446 if (rv == net::ERR_IO_PENDING) | 462 if (rv == net::ERR_IO_PENDING) |
447 rv = callback.WaitForResult(); | 463 rv = callback.WaitForResult(); |
448 EXPECT_EQ(net::OK, rv); | 464 EXPECT_EQ(net::OK, rv); |
449 | 465 |
450 scoped_ptr<net::SSLClientSocket> sock( | 466 scoped_ptr<net::SSLClientSocket> sock( |
451 socket_factory_->CreateSSLClientSocket( | 467 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
452 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 468 kDefaultSSLConfig)); |
453 | 469 |
454 rv = sock->Connect(&callback); | 470 rv = sock->Connect(&callback); |
455 if (rv == net::ERR_IO_PENDING) | 471 if (rv == net::ERR_IO_PENDING) |
456 rv = callback.WaitForResult(); | 472 rv = callback.WaitForResult(); |
457 EXPECT_EQ(net::OK, rv); | 473 EXPECT_EQ(net::OK, rv); |
458 | 474 |
459 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 475 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
460 scoped_refptr<net::IOBuffer> request_buffer( | 476 scoped_refptr<net::IOBuffer> request_buffer( |
461 new net::IOBuffer(arraysize(request_text) - 1)); | 477 new net::IOBuffer(arraysize(request_text) - 1)); |
462 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); | 478 memcpy(request_buffer->data(), request_text, arraysize(request_text) - 1); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 NULL, 0); | 527 NULL, 0); |
512 | 528 |
513 net::ClientSocket* transport = | 529 net::ClientSocket* transport = |
514 new net::MockTCPClientSocket(addr, NULL, &data); | 530 new net::MockTCPClientSocket(addr, NULL, &data); |
515 int rv = transport->Connect(&callback); | 531 int rv = transport->Connect(&callback); |
516 if (rv == net::ERR_IO_PENDING) | 532 if (rv == net::ERR_IO_PENDING) |
517 rv = callback.WaitForResult(); | 533 rv = callback.WaitForResult(); |
518 EXPECT_EQ(net::OK, rv); | 534 EXPECT_EQ(net::OK, rv); |
519 | 535 |
520 scoped_ptr<net::SSLClientSocket> sock( | 536 scoped_ptr<net::SSLClientSocket> sock( |
521 socket_factory_->CreateSSLClientSocket( | 537 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
522 transport, test_server.host_port_pair(), kDefaultSSLConfig, NULL)); | 538 kDefaultSSLConfig)); |
523 | 539 |
524 rv = sock->Connect(&callback); | 540 rv = sock->Connect(&callback); |
525 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); | 541 EXPECT_EQ(net::ERR_SSL_PROTOCOL_ERROR, rv); |
526 } | 542 } |
527 | 543 |
528 // TODO(rsleevi): Not implemented for Schannel. As Schannel is only used when | 544 // TODO(rsleevi): Not implemented for Schannel. As Schannel is only used when |
529 // performing client authentication, it will not be tested here. | 545 // performing client authentication, it will not be tested here. |
530 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { | 546 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { |
531 // Rather than exhaustively disabling every RC4 ciphersuite defined at | 547 // Rather than exhaustively disabling every RC4 ciphersuite defined at |
532 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, | 548 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, |
(...skipping 20 matching lines...) Expand all Loading... |
553 int rv = transport->Connect(&callback); | 569 int rv = transport->Connect(&callback); |
554 if (rv == net::ERR_IO_PENDING) | 570 if (rv == net::ERR_IO_PENDING) |
555 rv = callback.WaitForResult(); | 571 rv = callback.WaitForResult(); |
556 EXPECT_EQ(net::OK, rv); | 572 EXPECT_EQ(net::OK, rv); |
557 | 573 |
558 net::SSLConfig ssl_config; | 574 net::SSLConfig ssl_config; |
559 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) | 575 for (size_t i = 0; i < arraysize(kCiphersToDisable); ++i) |
560 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); | 576 ssl_config.disabled_cipher_suites.push_back(kCiphersToDisable[i]); |
561 | 577 |
562 scoped_ptr<net::SSLClientSocket> sock( | 578 scoped_ptr<net::SSLClientSocket> sock( |
563 socket_factory_->CreateSSLClientSocket( | 579 CreateSSLClientSocket(transport, test_server.host_port_pair(), |
564 transport, test_server.host_port_pair(), ssl_config, NULL)); | 580 ssl_config)); |
565 | 581 |
566 EXPECT_FALSE(sock->IsConnected()); | 582 EXPECT_FALSE(sock->IsConnected()); |
567 | 583 |
568 rv = sock->Connect(&callback); | 584 rv = sock->Connect(&callback); |
569 net::CapturingNetLog::EntryList entries; | 585 net::CapturingNetLog::EntryList entries; |
570 log.GetEntries(&entries); | 586 log.GetEntries(&entries); |
571 EXPECT_TRUE(net::LogContainsBeginEvent( | 587 EXPECT_TRUE(net::LogContainsBeginEvent( |
572 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); | 588 entries, 5, net::NetLog::TYPE_SSL_CONNECT)); |
573 | 589 |
574 // NSS has special handling that maps a handshake_failure alert received | 590 // NSS has special handling that maps a handshake_failure alert received |
(...skipping 12 matching lines...) Expand all Loading... |
587 log.GetEntries(&entries); | 603 log.GetEntries(&entries); |
588 net::ExpectLogContainsSomewhere(entries, 0, | 604 net::ExpectLogContainsSomewhere(entries, 0, |
589 net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 605 net::NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
590 net::NetLog::PHASE_NONE); | 606 net::NetLog::PHASE_NONE); |
591 | 607 |
592 // We cannot test sock->IsConnected(), as the NSS implementation disconnects | 608 // We cannot test sock->IsConnected(), as the NSS implementation disconnects |
593 // the socket when it encounters an error, whereas other implementations | 609 // the socket when it encounters an error, whereas other implementations |
594 // leave it connected. | 610 // leave it connected. |
595 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); | 611 EXPECT_TRUE(LogContainsSSLConnectEndEvent(entries, -1)); |
596 } | 612 } |
OLD | NEW |