Chromium Code Reviews| 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 "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 2703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2714 | 2714 |
| 2715 SSLConfig ssl_config = kDefaultSSLConfig; | 2715 SSLConfig ssl_config = kDefaultSSLConfig; |
| 2716 ssl_config.false_start_enabled = false; | 2716 ssl_config.false_start_enabled = false; |
| 2717 | 2717 |
| 2718 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 2718 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
| 2719 transport.Pass(), test_server.host_port_pair(), ssl_config)); | 2719 transport.Pass(), test_server.host_port_pair(), ssl_config)); |
| 2720 | 2720 |
| 2721 sock->SetHandshakeCompletionCallback(base::Bind( | 2721 sock->SetHandshakeCompletionCallback(base::Bind( |
| 2722 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); | 2722 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); |
| 2723 | 2723 |
| 2724 if (sock->IsConnected()) | |
| 2725 LOG(ERROR) << "SSL Socket prematurely connected"; | |
| 2726 | |
| 2727 rv = callback.GetResult(sock->Connect(callback.callback())); | 2724 rv = callback.GetResult(sock->Connect(callback.callback())); |
| 2728 | 2725 |
| 2729 EXPECT_EQ(OK, rv); | 2726 EXPECT_EQ(OK, rv); |
| 2730 EXPECT_TRUE(sock->IsConnected()); | 2727 EXPECT_TRUE(sock->IsConnected()); |
| 2731 EXPECT_TRUE(ran_handshake_completion_callback_); | 2728 EXPECT_TRUE(ran_handshake_completion_callback_); |
| 2732 } | 2729 } |
| 2733 | 2730 |
| 2731 // Tests that the completion callback is run with connections | |
| 2732 // that do not cache their session. | |
| 2733 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithNoneSessionCache) { | |
|
wtc
2014/08/07 02:10:12
Nit: what does "none session cache" mean?
| |
| 2734 SpawnedTestServer::SSLOptions ssl_options; | |
| 2735 ssl_options.disable_session_cache = true; | |
| 2736 SpawnedTestServer test_server( | |
| 2737 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); | |
| 2738 ASSERT_TRUE(test_server.Start()); | |
| 2739 | |
| 2740 AddressList addr; | |
| 2741 ASSERT_TRUE(test_server.GetAddressList(&addr)); | |
| 2742 | |
| 2743 scoped_ptr<StreamSocket> transport( | |
| 2744 new TCPClientSocket(addr, NULL, NetLog::Source())); | |
| 2745 | |
| 2746 TestCompletionCallback callback; | |
| 2747 int rv = transport->Connect(callback.callback()); | |
| 2748 if (rv == ERR_IO_PENDING) | |
| 2749 rv = callback.WaitForResult(); | |
| 2750 EXPECT_EQ(OK, rv); | |
| 2751 | |
| 2752 SSLConfig ssl_config = kDefaultSSLConfig; | |
| 2753 ssl_config.false_start_enabled = false; | |
| 2754 | |
| 2755 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | |
| 2756 transport.Pass(), test_server.host_port_pair(), ssl_config)); | |
| 2757 | |
| 2758 sock->SetHandshakeCompletionCallback(base::Bind( | |
| 2759 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); | |
| 2760 | |
| 2761 rv = callback.GetResult(sock->Connect(callback.callback())); | |
| 2762 | |
| 2763 EXPECT_EQ(OK, rv); | |
| 2764 EXPECT_TRUE(sock->IsConnected()); | |
| 2765 EXPECT_TRUE(ran_handshake_completion_callback_); | |
| 2766 } | |
| 2734 #endif // defined(USE_OPENSSL) | 2767 #endif // defined(USE_OPENSSL) |
| 2735 | 2768 |
| 2736 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { | 2769 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { |
| 2737 // False Start requires NPN and a forward-secret cipher suite. | 2770 // False Start requires NPN and a forward-secret cipher suite. |
| 2738 SpawnedTestServer::SSLOptions server_options; | 2771 SpawnedTestServer::SSLOptions server_options; |
| 2739 server_options.key_exchanges = | 2772 server_options.key_exchanges = |
| 2740 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA; | 2773 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA; |
| 2741 server_options.enable_npn = true; | 2774 server_options.enable_npn = true; |
| 2742 SSLConfig client_config; | 2775 SSLConfig client_config; |
| 2743 client_config.next_protos.push_back("http/1.1"); | 2776 client_config.next_protos.push_back("http/1.1"); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2895 ssl_config.channel_id_enabled = true; | 2928 ssl_config.channel_id_enabled = true; |
| 2896 | 2929 |
| 2897 int rv; | 2930 int rv; |
| 2898 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 2931 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 2899 | 2932 |
| 2900 EXPECT_EQ(ERR_UNEXPECTED, rv); | 2933 EXPECT_EQ(ERR_UNEXPECTED, rv); |
| 2901 EXPECT_FALSE(sock_->IsConnected()); | 2934 EXPECT_FALSE(sock_->IsConnected()); |
| 2902 } | 2935 } |
| 2903 | 2936 |
| 2904 } // namespace net | 2937 } // namespace net |
| OLD | NEW |