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 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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()) | 2724 if (sock->IsConnected()) |
2725 LOG(ERROR) << "SSL Socket prematurely connected"; | 2725 LOG(ERROR) << "SSL Socket prematurely connected"; |
Ryan Sleevi
2014/08/07 00:27:41
Pst: Nuke these two lines :)
mshelley
2014/08/07 00:55:05
Done.
| |
2726 | 2726 |
2727 rv = callback.GetResult(sock->Connect(callback.callback())); | 2727 rv = callback.GetResult(sock->Connect(callback.callback())); |
2728 | 2728 |
2729 EXPECT_EQ(OK, rv); | 2729 EXPECT_EQ(OK, rv); |
2730 EXPECT_TRUE(sock->IsConnected()); | 2730 EXPECT_TRUE(sock->IsConnected()); |
2731 EXPECT_TRUE(ran_handshake_completion_callback_); | 2731 EXPECT_TRUE(ran_handshake_completion_callback_); |
2732 } | 2732 } |
2733 | 2733 |
2734 // Tests that the completion callback is run with connections | |
2735 // that do not cache their session. | |
2736 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithNoneSessionCache) { | |
2737 SpawnedTestServer::SSLOptions ssl_options; | |
2738 ssl_options.disable_session_cache = true; | |
2739 SpawnedTestServer test_server( | |
2740 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); | |
2741 ASSERT_TRUE(test_server.Start()); | |
2742 | |
2743 AddressList addr; | |
2744 ASSERT_TRUE(test_server.GetAddressList(&addr)); | |
2745 | |
2746 scoped_ptr<StreamSocket> transport( | |
2747 new TCPClientSocket(addr, NULL, NetLog::Source())); | |
2748 | |
2749 TestCompletionCallback callback; | |
2750 int rv = transport->Connect(callback.callback()); | |
2751 if (rv == ERR_IO_PENDING) | |
2752 rv = callback.WaitForResult(); | |
2753 EXPECT_EQ(OK, rv); | |
2754 | |
2755 SSLConfig ssl_config = kDefaultSSLConfig; | |
2756 ssl_config.false_start_enabled = false; | |
2757 | |
2758 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | |
2759 transport.Pass(), test_server.host_port_pair(), ssl_config)); | |
2760 | |
2761 sock->SetHandshakeCompletionCallback(base::Bind( | |
2762 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); | |
2763 | |
2764 rv = callback.GetResult(sock->Connect(callback.callback())); | |
2765 | |
2766 EXPECT_EQ(OK, rv); | |
2767 EXPECT_TRUE(sock->IsConnected()); | |
2768 EXPECT_TRUE(ran_handshake_completion_callback_); | |
2769 } | |
2734 #endif // defined(USE_OPENSSL) | 2770 #endif // defined(USE_OPENSSL) |
2735 | 2771 |
2736 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { | 2772 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { |
2737 // False Start requires NPN and a forward-secret cipher suite. | 2773 // False Start requires NPN and a forward-secret cipher suite. |
2738 SpawnedTestServer::SSLOptions server_options; | 2774 SpawnedTestServer::SSLOptions server_options; |
2739 server_options.key_exchanges = | 2775 server_options.key_exchanges = |
2740 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA; | 2776 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA; |
2741 server_options.enable_npn = true; | 2777 server_options.enable_npn = true; |
2742 SSLConfig client_config; | 2778 SSLConfig client_config; |
2743 client_config.next_protos.push_back("http/1.1"); | 2779 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; | 2931 ssl_config.channel_id_enabled = true; |
2896 | 2932 |
2897 int rv; | 2933 int rv; |
2898 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 2934 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
2899 | 2935 |
2900 EXPECT_EQ(ERR_UNEXPECTED, rv); | 2936 EXPECT_EQ(ERR_UNEXPECTED, rv); |
2901 EXPECT_FALSE(sock_->IsConnected()); | 2937 EXPECT_FALSE(sock_->IsConnected()); |
2902 } | 2938 } |
2903 | 2939 |
2904 } // namespace net | 2940 } // namespace net |
OLD | NEW |