OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 int buffer_size_; | 155 int buffer_size_; |
156 | 156 |
157 scoped_refptr<IOBuffer> user_read_buf_; | 157 scoped_refptr<IOBuffer> user_read_buf_; |
158 CompletionCallback user_read_callback_; | 158 CompletionCallback user_read_callback_; |
159 }; | 159 }; |
160 | 160 |
161 ReadBufferingStreamSocket::ReadBufferingStreamSocket( | 161 ReadBufferingStreamSocket::ReadBufferingStreamSocket( |
162 scoped_ptr<StreamSocket> transport) | 162 scoped_ptr<StreamSocket> transport) |
163 : WrappedStreamSocket(transport.Pass()), | 163 : WrappedStreamSocket(transport.Pass()), |
164 read_buffer_(new GrowableIOBuffer()), | 164 read_buffer_(new GrowableIOBuffer()), |
165 buffer_size_(0) {} | 165 buffer_size_(0) { |
| 166 } |
166 | 167 |
167 void ReadBufferingStreamSocket::SetBufferSize(int size) { | 168 void ReadBufferingStreamSocket::SetBufferSize(int size) { |
168 DCHECK(!user_read_buf_.get()); | 169 DCHECK(!user_read_buf_.get()); |
169 buffer_size_ = size; | 170 buffer_size_ = size; |
170 read_buffer_->SetCapacity(size); | 171 read_buffer_->SetCapacity(size); |
171 } | 172 } |
172 | 173 |
173 int ReadBufferingStreamSocket::Read(IOBuffer* buf, | 174 int ReadBufferingStreamSocket::Read(IOBuffer* buf, |
174 int buf_len, | 175 int buf_len, |
175 const CompletionCallback& callback) { | 176 const CompletionCallback& callback) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 292 |
292 DISALLOW_COPY_AND_ASSIGN(SynchronousErrorStreamSocket); | 293 DISALLOW_COPY_AND_ASSIGN(SynchronousErrorStreamSocket); |
293 }; | 294 }; |
294 | 295 |
295 SynchronousErrorStreamSocket::SynchronousErrorStreamSocket( | 296 SynchronousErrorStreamSocket::SynchronousErrorStreamSocket( |
296 scoped_ptr<StreamSocket> transport) | 297 scoped_ptr<StreamSocket> transport) |
297 : WrappedStreamSocket(transport.Pass()), | 298 : WrappedStreamSocket(transport.Pass()), |
298 have_read_error_(false), | 299 have_read_error_(false), |
299 pending_read_error_(OK), | 300 pending_read_error_(OK), |
300 have_write_error_(false), | 301 have_write_error_(false), |
301 pending_write_error_(OK) {} | 302 pending_write_error_(OK) { |
| 303 } |
302 | 304 |
303 int SynchronousErrorStreamSocket::Read(IOBuffer* buf, | 305 int SynchronousErrorStreamSocket::Read(IOBuffer* buf, |
304 int buf_len, | 306 int buf_len, |
305 const CompletionCallback& callback) { | 307 const CompletionCallback& callback) { |
306 if (have_read_error_) | 308 if (have_read_error_) |
307 return pending_read_error_; | 309 return pending_read_error_; |
308 return transport_->Read(buf, buf_len, callback); | 310 return transport_->Read(buf, buf_len, callback); |
309 } | 311 } |
310 | 312 |
311 int SynchronousErrorStreamSocket::Write(IOBuffer* buf, | 313 int SynchronousErrorStreamSocket::Write(IOBuffer* buf, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // WaitForWrite() wait loop. | 389 // WaitForWrite() wait loop. |
388 scoped_ptr<base::RunLoop> write_loop_; | 390 scoped_ptr<base::RunLoop> write_loop_; |
389 }; | 391 }; |
390 | 392 |
391 FakeBlockingStreamSocket::FakeBlockingStreamSocket( | 393 FakeBlockingStreamSocket::FakeBlockingStreamSocket( |
392 scoped_ptr<StreamSocket> transport) | 394 scoped_ptr<StreamSocket> transport) |
393 : WrappedStreamSocket(transport.Pass()), | 395 : WrappedStreamSocket(transport.Pass()), |
394 should_block_read_(false), | 396 should_block_read_(false), |
395 pending_read_result_(ERR_IO_PENDING), | 397 pending_read_result_(ERR_IO_PENDING), |
396 should_block_write_(false), | 398 should_block_write_(false), |
397 pending_write_len_(-1) {} | 399 pending_write_len_(-1) { |
| 400 } |
398 | 401 |
399 int FakeBlockingStreamSocket::Read(IOBuffer* buf, | 402 int FakeBlockingStreamSocket::Read(IOBuffer* buf, |
400 int len, | 403 int len, |
401 const CompletionCallback& callback) { | 404 const CompletionCallback& callback) { |
402 DCHECK(pending_read_callback_.is_null()); | 405 DCHECK(pending_read_callback_.is_null()); |
403 DCHECK_EQ(ERR_IO_PENDING, pending_read_result_); | 406 DCHECK_EQ(ERR_IO_PENDING, pending_read_result_); |
404 DCHECK(!callback.is_null()); | 407 DCHECK(!callback.is_null()); |
405 | 408 |
406 int rv = transport_->Read(buf, len, base::Bind( | 409 int rv = |
407 &FakeBlockingStreamSocket::OnReadCompleted, base::Unretained(this))); | 410 transport_->Read(buf, |
| 411 len, |
| 412 base::Bind(&FakeBlockingStreamSocket::OnReadCompleted, |
| 413 base::Unretained(this))); |
408 if (rv == ERR_IO_PENDING) { | 414 if (rv == ERR_IO_PENDING) { |
409 // Save the callback to be called later. | 415 // Save the callback to be called later. |
410 pending_read_callback_ = callback; | 416 pending_read_callback_ = callback; |
411 } else if (should_block_read_) { | 417 } else if (should_block_read_) { |
412 // Save the callback and read result to be called later. | 418 // Save the callback and read result to be called later. |
413 pending_read_callback_ = callback; | 419 pending_read_callback_ = callback; |
414 OnReadCompleted(rv); | 420 OnReadCompleted(rv); |
415 rv = ERR_IO_PENDING; | 421 rv = ERR_IO_PENDING; |
416 } | 422 } |
417 return rv; | 423 return rv; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 485 |
480 void FakeBlockingStreamSocket::UnblockWrite() { | 486 void FakeBlockingStreamSocket::UnblockWrite() { |
481 DCHECK(should_block_write_); | 487 DCHECK(should_block_write_); |
482 should_block_write_ = false; | 488 should_block_write_ = false; |
483 | 489 |
484 // Do nothing if UnblockWrite() was called after BlockWrite(), | 490 // Do nothing if UnblockWrite() was called after BlockWrite(), |
485 // without a Write() in between. | 491 // without a Write() in between. |
486 if (!pending_write_buf_) | 492 if (!pending_write_buf_) |
487 return; | 493 return; |
488 | 494 |
489 int rv = transport_->Write(pending_write_buf_, pending_write_len_, | 495 int rv = transport_->Write( |
490 pending_write_callback_); | 496 pending_write_buf_, pending_write_len_, pending_write_callback_); |
491 pending_write_buf_ = NULL; | 497 pending_write_buf_ = NULL; |
492 pending_write_len_ = -1; | 498 pending_write_len_ = -1; |
493 if (rv == ERR_IO_PENDING) { | 499 if (rv == ERR_IO_PENDING) { |
494 pending_write_callback_.Reset(); | 500 pending_write_callback_.Reset(); |
495 } else { | 501 } else { |
496 base::ResetAndReturn(&pending_write_callback_).Run(rv); | 502 base::ResetAndReturn(&pending_write_callback_).Run(rv); |
497 } | 503 } |
498 } | 504 } |
499 | 505 |
500 void FakeBlockingStreamSocket::WaitForWrite() { | 506 void FakeBlockingStreamSocket::WaitForWrite() { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 630 |
625 return request_info; | 631 return request_info; |
626 } | 632 } |
627 }; | 633 }; |
628 | 634 |
629 class SSLClientSocketFalseStartTest : public SSLClientSocketTest { | 635 class SSLClientSocketFalseStartTest : public SSLClientSocketTest { |
630 protected: | 636 protected: |
631 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options, | 637 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options, |
632 const SSLConfig& client_config, | 638 const SSLConfig& client_config, |
633 bool expect_false_start) { | 639 bool expect_false_start) { |
634 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 640 SpawnedTestServer test_server( |
635 server_options, | 641 SpawnedTestServer::TYPE_HTTPS, server_options, base::FilePath()); |
636 base::FilePath()); | |
637 ASSERT_TRUE(test_server.Start()); | 642 ASSERT_TRUE(test_server.Start()); |
638 | 643 |
639 AddressList addr; | 644 AddressList addr; |
640 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 645 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
641 | 646 |
642 TestCompletionCallback callback; | 647 TestCompletionCallback callback; |
643 scoped_ptr<StreamSocket> real_transport( | 648 scoped_ptr<StreamSocket> real_transport( |
644 new TCPClientSocket(addr, NULL, NetLog::Source())); | 649 new TCPClientSocket(addr, NULL, NetLog::Source())); |
645 scoped_ptr<FakeBlockingStreamSocket> transport( | 650 scoped_ptr<FakeBlockingStreamSocket> transport( |
646 new FakeBlockingStreamSocket(real_transport.Pass())); | 651 new FakeBlockingStreamSocket(real_transport.Pass())); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 EXPECT_EQ(OK, rv); | 688 EXPECT_EQ(OK, rv); |
684 EXPECT_TRUE(sock->IsConnected()); | 689 EXPECT_TRUE(sock->IsConnected()); |
685 | 690 |
686 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; | 691 const char request_text[] = "GET / HTTP/1.0\r\n\r\n"; |
687 static const int kRequestTextSize = | 692 static const int kRequestTextSize = |
688 static_cast<int>(arraysize(request_text) - 1); | 693 static_cast<int>(arraysize(request_text) - 1); |
689 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize)); | 694 scoped_refptr<IOBuffer> request_buffer(new IOBuffer(kRequestTextSize)); |
690 memcpy(request_buffer->data(), request_text, kRequestTextSize); | 695 memcpy(request_buffer->data(), request_text, kRequestTextSize); |
691 | 696 |
692 // Write the request. | 697 // Write the request. |
693 rv = callback.GetResult(sock->Write(request_buffer.get(), | 698 rv = callback.GetResult(sock->Write( |
694 kRequestTextSize, | 699 request_buffer.get(), kRequestTextSize, callback.callback())); |
695 callback.callback())); | |
696 EXPECT_EQ(kRequestTextSize, rv); | 700 EXPECT_EQ(kRequestTextSize, rv); |
697 | 701 |
698 // The read will hang; it's waiting for the peer to complete the | 702 // The read will hang; it's waiting for the peer to complete the |
699 // handshake, and the handshake is still blocked. | 703 // handshake, and the handshake is still blocked. |
700 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); | 704 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); |
701 rv = sock->Read(buf.get(), 4096, callback.callback()); | 705 rv = sock->Read(buf.get(), 4096, callback.callback()); |
702 | 706 |
703 // After releasing reads, the connection proceeds. | 707 // After releasing reads, the connection proceeds. |
704 raw_transport->UnblockReadResult(); | 708 raw_transport->UnblockReadResult(); |
705 rv = callback.GetResult(rv); | 709 rv = callback.GetResult(rv); |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 TEST_F(SSLClientSocketTest, PrematureApplicationData) { | 1697 TEST_F(SSLClientSocketTest, PrematureApplicationData) { |
1694 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 1698 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, |
1695 SpawnedTestServer::kLocalhost, | 1699 SpawnedTestServer::kLocalhost, |
1696 base::FilePath()); | 1700 base::FilePath()); |
1697 ASSERT_TRUE(test_server.Start()); | 1701 ASSERT_TRUE(test_server.Start()); |
1698 | 1702 |
1699 AddressList addr; | 1703 AddressList addr; |
1700 TestCompletionCallback callback; | 1704 TestCompletionCallback callback; |
1701 | 1705 |
1702 static const unsigned char application_data[] = { | 1706 static const unsigned char application_data[] = { |
1703 0x17, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x46, 0x03, 0x01, 0x4b, | 1707 0x17, 0x03, 0x01, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x46, 0x03, 0x01, |
1704 0xc2, 0xf8, 0xb2, 0xc1, 0x56, 0x42, 0xb9, 0x57, 0x7f, 0xde, 0x87, 0x46, | 1708 0x4b, 0xc2, 0xf8, 0xb2, 0xc1, 0x56, 0x42, 0xb9, 0x57, 0x7f, 0xde, |
1705 0xf7, 0xa3, 0x52, 0x42, 0x21, 0xf0, 0x13, 0x1c, 0x9c, 0x83, 0x88, 0xd6, | 1709 0x87, 0x46, 0xf7, 0xa3, 0x52, 0x42, 0x21, 0xf0, 0x13, 0x1c, 0x9c, |
1706 0x93, 0x0c, 0xf6, 0x36, 0x30, 0x05, 0x7e, 0x20, 0xb5, 0xb5, 0x73, 0x36, | 1710 0x83, 0x88, 0xd6, 0x93, 0x0c, 0xf6, 0x36, 0x30, 0x05, 0x7e, 0x20, |
1707 0x53, 0x83, 0x0a, 0xfc, 0x17, 0x63, 0xbf, 0xa0, 0xe4, 0x42, 0x90, 0x0d, | 1711 0xb5, 0xb5, 0x73, 0x36, 0x53, 0x83, 0x0a, 0xfc, 0x17, 0x63, 0xbf, |
1708 0x2f, 0x18, 0x6d, 0x20, 0xd8, 0x36, 0x3f, 0xfc, 0xe6, 0x01, 0xfa, 0x0f, | 1712 0xa0, 0xe4, 0x42, 0x90, 0x0d, 0x2f, 0x18, 0x6d, 0x20, 0xd8, 0x36, |
1709 0xa5, 0x75, 0x7f, 0x09, 0x00, 0x04, 0x00, 0x16, 0x03, 0x01, 0x11, 0x57, | 1713 0x3f, 0xfc, 0xe6, 0x01, 0xfa, 0x0f, 0xa5, 0x75, 0x7f, 0x09, 0x00, |
1710 0x0b, 0x00, 0x11, 0x53, 0x00, 0x11, 0x50, 0x00, 0x06, 0x22, 0x30, 0x82, | 1714 0x04, 0x00, 0x16, 0x03, 0x01, 0x11, 0x57, 0x0b, 0x00, 0x11, 0x53, |
1711 0x06, 0x1e, 0x30, 0x82, 0x05, 0x06, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, | 1715 0x00, 0x11, 0x50, 0x00, 0x06, 0x22, 0x30, 0x82, 0x06, 0x1e, 0x30, |
1712 0x0a}; | 1716 0x82, 0x05, 0x06, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x0a}; |
1713 | 1717 |
1714 // All reads and writes complete synchronously (async=false). | 1718 // All reads and writes complete synchronously (async=false). |
1715 MockRead data_reads[] = { | 1719 MockRead data_reads[] = { |
1716 MockRead(SYNCHRONOUS, | 1720 MockRead(SYNCHRONOUS, |
1717 reinterpret_cast<const char*>(application_data), | 1721 reinterpret_cast<const char*>(application_data), |
1718 arraysize(application_data)), | 1722 arraysize(application_data)), |
1719 MockRead(SYNCHRONOUS, OK), }; | 1723 MockRead(SYNCHRONOUS, OK), |
| 1724 }; |
1720 | 1725 |
1721 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 1726 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
1722 | 1727 |
1723 scoped_ptr<StreamSocket> transport( | 1728 scoped_ptr<StreamSocket> transport( |
1724 new MockTCPClientSocket(addr, NULL, &data)); | 1729 new MockTCPClientSocket(addr, NULL, &data)); |
1725 int rv = transport->Connect(callback.callback()); | 1730 int rv = transport->Connect(callback.callback()); |
1726 if (rv == ERR_IO_PENDING) | 1731 if (rv == ERR_IO_PENDING) |
1727 rv = callback.WaitForResult(); | 1732 rv = callback.WaitForResult(); |
1728 EXPECT_EQ(OK, rv); | 1733 EXPECT_EQ(OK, rv); |
1729 | 1734 |
1730 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 1735 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
1731 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); | 1736 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); |
1732 | 1737 |
1733 rv = sock->Connect(callback.callback()); | 1738 rv = sock->Connect(callback.callback()); |
1734 if (rv == ERR_IO_PENDING) | 1739 if (rv == ERR_IO_PENDING) |
1735 rv = callback.WaitForResult(); | 1740 rv = callback.WaitForResult(); |
1736 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); | 1741 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); |
1737 } | 1742 } |
1738 | 1743 |
1739 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { | 1744 TEST_F(SSLClientSocketTest, CipherSuiteDisables) { |
1740 // Rather than exhaustively disabling every RC4 ciphersuite defined at | 1745 // Rather than exhaustively disabling every RC4 ciphersuite defined at |
1741 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, | 1746 // http://www.iana.org/assignments/tls-parameters/tls-parameters.xml, |
1742 // only disabling those cipher suites that the test server actually | 1747 // only disabling those cipher suites that the test server actually |
1743 // implements. | 1748 // implements. |
1744 const uint16 kCiphersToDisable[] = {0x0005, // TLS_RSA_WITH_RC4_128_SHA | 1749 const uint16 kCiphersToDisable[] = { |
| 1750 0x0005, // TLS_RSA_WITH_RC4_128_SHA |
1745 }; | 1751 }; |
1746 | 1752 |
1747 SpawnedTestServer::SSLOptions ssl_options; | 1753 SpawnedTestServer::SSLOptions ssl_options; |
1748 // Enable only RC4 on the test server. | 1754 // Enable only RC4 on the test server. |
1749 ssl_options.bulk_ciphers = SpawnedTestServer::SSLOptions::BULK_CIPHER_RC4; | 1755 ssl_options.bulk_ciphers = SpawnedTestServer::SSLOptions::BULK_CIPHER_RC4; |
1750 SpawnedTestServer test_server( | 1756 SpawnedTestServer test_server( |
1751 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); | 1757 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); |
1752 ASSERT_TRUE(test_server.Start()); | 1758 ASSERT_TRUE(test_server.Start()); |
1753 | 1759 |
1754 AddressList addr; | 1760 AddressList addr; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 0x13, 0x1c, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x43, 0x6f, 0x6e, | 2089 0x13, 0x1c, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x43, 0x6f, 0x6e, |
2084 0x73, 0x75, 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x28, 0x50, 0x74, 0x79, | 2090 0x73, 0x75, 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x28, 0x50, 0x74, 0x79, |
2085 0x29, 0x20, 0x4c, 0x74, 0x64, 0x2e, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, | 2091 0x29, 0x20, 0x4c, 0x74, 0x64, 0x2e, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, |
2086 0x55, 0x04, 0x03, 0x13, 0x0d, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, | 2092 0x55, 0x04, 0x03, 0x13, 0x0d, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, |
2087 0x53, 0x47, 0x43, 0x20, 0x43, 0x41}; | 2093 0x53, 0x47, 0x43, 0x20, 0x43, 0x41}; |
2088 const size_t kThawteLen = sizeof(kThawteDN); | 2094 const size_t kThawteLen = sizeof(kThawteDN); |
2089 | 2095 |
2090 const base::FilePath::CharType kDiginotarFile[] = | 2096 const base::FilePath::CharType kDiginotarFile[] = |
2091 FILE_PATH_LITERAL("diginotar_root_ca.pem"); | 2097 FILE_PATH_LITERAL("diginotar_root_ca.pem"); |
2092 const unsigned char kDiginotarDN[] = { | 2098 const unsigned char kDiginotarDN[] = { |
2093 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, | 2099 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, |
2094 0x02, 0x4e, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x0a, | 2100 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, |
2095 0x13, 0x09, 0x44, 0x69, 0x67, 0x69, 0x4e, 0x6f, 0x74, 0x61, 0x72, 0x31, | 2101 0x04, 0x0a, 0x13, 0x09, 0x44, 0x69, 0x67, 0x69, 0x4e, 0x6f, 0x74, |
2096 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x11, 0x44, 0x69, | 2102 0x61, 0x72, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, |
2097 0x67, 0x69, 0x4e, 0x6f, 0x74, 0x61, 0x72, 0x20, 0x52, 0x6f, 0x6f, 0x74, | 2103 0x13, 0x11, 0x44, 0x69, 0x67, 0x69, 0x4e, 0x6f, 0x74, 0x61, 0x72, |
2098 0x20, 0x43, 0x41, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48, | 2104 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x20, 0x30, |
2099 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x11, 0x69, 0x6e, 0x66, 0x6f, | 2105 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, |
2100 0x40, 0x64, 0x69, 0x67, 0x69, 0x6e, 0x6f, 0x74, 0x61, 0x72, 0x2e, 0x6e, | 2106 0x01, 0x16, 0x11, 0x69, 0x6e, 0x66, 0x6f, 0x40, 0x64, 0x69, 0x67, |
2101 0x6c}; | 2107 0x69, 0x6e, 0x6f, 0x74, 0x61, 0x72, 0x2e, 0x6e, 0x6c}; |
2102 const size_t kDiginotarLen = sizeof(kDiginotarDN); | 2108 const size_t kDiginotarLen = sizeof(kDiginotarDN); |
2103 | 2109 |
2104 SpawnedTestServer::SSLOptions ssl_options; | 2110 SpawnedTestServer::SSLOptions ssl_options; |
2105 ssl_options.request_client_certificate = true; | 2111 ssl_options.request_client_certificate = true; |
2106 ssl_options.client_authorities.push_back( | 2112 ssl_options.client_authorities.push_back( |
2107 GetTestClientCertsDirectory().Append(kThawteFile)); | 2113 GetTestClientCertsDirectory().Append(kThawteFile)); |
2108 ssl_options.client_authorities.push_back( | 2114 ssl_options.client_authorities.push_back( |
2109 GetTestClientCertsDirectory().Append(kDiginotarFile)); | 2115 GetTestClientCertsDirectory().Append(kDiginotarFile)); |
2110 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options); | 2116 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options); |
2111 ASSERT_TRUE(request_info.get()); | 2117 ASSERT_TRUE(request_info.get()); |
2112 ASSERT_EQ(2u, request_info->cert_authorities.size()); | 2118 ASSERT_EQ(2u, request_info->cert_authorities.size()); |
2113 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), | 2119 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), |
2114 request_info->cert_authorities[0]); | 2120 request_info->cert_authorities[0]); |
2115 EXPECT_EQ( | 2121 EXPECT_EQ( |
2116 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), | 2122 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), |
2117 request_info->cert_authorities[1]); | 2123 request_info->cert_authorities[1]); |
2118 } | 2124 } |
2119 | 2125 |
2120 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) { | 2126 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) { |
2121 SpawnedTestServer::SSLOptions ssl_options; | 2127 SpawnedTestServer::SSLOptions ssl_options; |
2122 ssl_options.signed_cert_timestamps_tls_ext = "test"; | 2128 ssl_options.signed_cert_timestamps_tls_ext = "test"; |
2123 | 2129 |
2124 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 2130 SpawnedTestServer test_server( |
2125 ssl_options, | 2131 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); |
2126 base::FilePath()); | |
2127 ASSERT_TRUE(test_server.Start()); | 2132 ASSERT_TRUE(test_server.Start()); |
2128 | 2133 |
2129 AddressList addr; | 2134 AddressList addr; |
2130 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 2135 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
2131 | 2136 |
2132 TestCompletionCallback callback; | 2137 TestCompletionCallback callback; |
2133 CapturingNetLog log; | 2138 CapturingNetLog log; |
2134 scoped_ptr<StreamSocket> transport( | 2139 scoped_ptr<StreamSocket> transport( |
2135 new TCPClientSocket(addr, &log, NetLog::Source())); | 2140 new TCPClientSocket(addr, &log, NetLog::Source())); |
2136 int rv = transport->Connect(callback.callback()); | 2141 int rv = transport->Connect(callback.callback()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2170 } | 2175 } |
2171 | 2176 |
2172 // Test that enabling Signed Certificate Timestamps enables OCSP stapling. | 2177 // Test that enabling Signed Certificate Timestamps enables OCSP stapling. |
2173 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledOCSP) { | 2178 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledOCSP) { |
2174 SpawnedTestServer::SSLOptions ssl_options; | 2179 SpawnedTestServer::SSLOptions ssl_options; |
2175 ssl_options.staple_ocsp_response = true; | 2180 ssl_options.staple_ocsp_response = true; |
2176 // The test server currently only knows how to generate OCSP responses | 2181 // The test server currently only knows how to generate OCSP responses |
2177 // for a freshly minted certificate. | 2182 // for a freshly minted certificate. |
2178 ssl_options.server_certificate = SpawnedTestServer::SSLOptions::CERT_AUTO; | 2183 ssl_options.server_certificate = SpawnedTestServer::SSLOptions::CERT_AUTO; |
2179 | 2184 |
2180 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 2185 SpawnedTestServer test_server( |
2181 ssl_options, | 2186 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); |
2182 base::FilePath()); | |
2183 ASSERT_TRUE(test_server.Start()); | 2187 ASSERT_TRUE(test_server.Start()); |
2184 | 2188 |
2185 AddressList addr; | 2189 AddressList addr; |
2186 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 2190 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
2187 | 2191 |
2188 TestCompletionCallback callback; | 2192 TestCompletionCallback callback; |
2189 CapturingNetLog log; | 2193 CapturingNetLog log; |
2190 scoped_ptr<StreamSocket> transport( | 2194 scoped_ptr<StreamSocket> transport( |
2191 new TCPClientSocket(addr, &log, NetLog::Source())); | 2195 new TCPClientSocket(addr, &log, NetLog::Source())); |
2192 int rv = transport->Connect(callback.callback()); | 2196 int rv = transport->Connect(callback.callback()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 #endif | 2229 #endif |
2226 | 2230 |
2227 sock->Disconnect(); | 2231 sock->Disconnect(); |
2228 EXPECT_FALSE(sock->IsConnected()); | 2232 EXPECT_FALSE(sock->IsConnected()); |
2229 } | 2233 } |
2230 | 2234 |
2231 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsDisabled) { | 2235 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsDisabled) { |
2232 SpawnedTestServer::SSLOptions ssl_options; | 2236 SpawnedTestServer::SSLOptions ssl_options; |
2233 ssl_options.signed_cert_timestamps_tls_ext = "test"; | 2237 ssl_options.signed_cert_timestamps_tls_ext = "test"; |
2234 | 2238 |
2235 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 2239 SpawnedTestServer test_server( |
2236 ssl_options, | 2240 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); |
2237 base::FilePath()); | |
2238 ASSERT_TRUE(test_server.Start()); | 2241 ASSERT_TRUE(test_server.Start()); |
2239 | 2242 |
2240 AddressList addr; | 2243 AddressList addr; |
2241 ASSERT_TRUE(test_server.GetAddressList(&addr)); | 2244 ASSERT_TRUE(test_server.GetAddressList(&addr)); |
2242 | 2245 |
2243 TestCompletionCallback callback; | 2246 TestCompletionCallback callback; |
2244 CapturingNetLog log; | 2247 CapturingNetLog log; |
2245 scoped_ptr<StreamSocket> transport( | 2248 scoped_ptr<StreamSocket> transport( |
2246 new TCPClientSocket(addr, &log, NetLog::Source())); | 2249 new TCPClientSocket(addr, &log, NetLog::Source())); |
2247 int rv = transport->Connect(callback.callback()); | 2250 int rv = transport->Connect(callback.callback()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 SpawnedTestServer::SSLOptions server_options; | 2360 SpawnedTestServer::SSLOptions server_options; |
2358 server_options.key_exchanges = | 2361 server_options.key_exchanges = |
2359 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_RSA; | 2362 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_RSA; |
2360 server_options.enable_npn = true; | 2363 server_options.enable_npn = true; |
2361 SSLConfig client_config; | 2364 SSLConfig client_config; |
2362 client_config.next_protos.push_back("http/1.1"); | 2365 client_config.next_protos.push_back("http/1.1"); |
2363 TestFalseStart(server_options, client_config, false); | 2366 TestFalseStart(server_options, client_config, false); |
2364 } | 2367 } |
2365 | 2368 |
2366 } // namespace net | 2369 } // namespace net |
OLD | NEW |