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/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 | 3124 |
3125 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( | 3125 scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket( |
3126 transport.Pass(), test_server.host_port_pair(), config)); | 3126 transport.Pass(), test_server.host_port_pair(), config)); |
3127 | 3127 |
3128 rv = sock->Connect(callback.callback()); | 3128 rv = sock->Connect(callback.callback()); |
3129 rv = callback.GetResult(rv); | 3129 rv = callback.GetResult(rv); |
3130 | 3130 |
3131 EXPECT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, rv); | 3131 EXPECT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, rv); |
3132 } | 3132 } |
3133 | 3133 |
| 3134 TEST_F(SSLClientSocketChannelIDTest, TokenBindingEnabled) { |
| 3135 SpawnedTestServer::SSLOptions ssl_options; |
| 3136 ssl_options.supported_token_binding_params.push_back( |
| 3137 TB_PARAM_ECDSAP256_SHA256); |
| 3138 ssl_options.disable_channel_id = true; |
| 3139 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
| 3140 |
| 3141 EnableChannelID(); |
| 3142 SSLConfig ssl_config; |
| 3143 ssl_config.token_binding_params.push_back(TB_PARAM_ECDSAP256_SHA256); |
| 3144 ssl_config.channel_id_enabled = true; |
| 3145 |
| 3146 int rv; |
| 3147 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 3148 EXPECT_EQ(OK, rv); |
| 3149 SSLInfo info; |
| 3150 EXPECT_TRUE(sock_->GetSSLInfo(&info)); |
| 3151 EXPECT_TRUE(info.token_binding_negotiated); |
| 3152 } |
| 3153 |
| 3154 TEST_F(SSLClientSocketChannelIDTest, TokenBindingFailsWithEmsDisabled) { |
| 3155 SpawnedTestServer::SSLOptions ssl_options; |
| 3156 ssl_options.supported_token_binding_params.push_back( |
| 3157 TB_PARAM_ECDSAP256_SHA256); |
| 3158 ssl_options.disable_extended_master_secret = true; |
| 3159 ssl_options.disable_channel_id = true; |
| 3160 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
| 3161 |
| 3162 EnableChannelID(); |
| 3163 SSLConfig ssl_config; |
| 3164 ssl_config.token_binding_params.push_back(TB_PARAM_ECDSAP256_SHA256); |
| 3165 ssl_config.channel_id_enabled = true; |
| 3166 |
| 3167 int rv; |
| 3168 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 3169 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); |
| 3170 } |
| 3171 |
3134 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { | 3172 TEST_F(SSLClientSocketFalseStartTest, FalseStartEnabled) { |
3135 // False Start requires NPN/ALPN, ECDHE, and an AEAD. | 3173 // False Start requires NPN/ALPN, ECDHE, and an AEAD. |
3136 SpawnedTestServer::SSLOptions server_options; | 3174 SpawnedTestServer::SSLOptions server_options; |
3137 server_options.key_exchanges = | 3175 server_options.key_exchanges = |
3138 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_ECDHE_RSA; | 3176 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_ECDHE_RSA; |
3139 server_options.bulk_ciphers = | 3177 server_options.bulk_ciphers = |
3140 SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; | 3178 SpawnedTestServer::SSLOptions::BULK_CIPHER_AES128GCM; |
3141 server_options.enable_npn = true; | 3179 server_options.enable_npn = true; |
3142 SSLConfig client_config; | 3180 SSLConfig client_config; |
3143 client_config.next_protos.push_back(kProtoHTTP11); | 3181 client_config.next_protos.push_back(kProtoHTTP11); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 ssl_config.channel_id_enabled = true; | 3450 ssl_config.channel_id_enabled = true; |
3413 | 3451 |
3414 int rv; | 3452 int rv; |
3415 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3453 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3416 | 3454 |
3417 EXPECT_EQ(ERR_UNEXPECTED, rv); | 3455 EXPECT_EQ(ERR_UNEXPECTED, rv); |
3418 EXPECT_FALSE(sock_->IsConnected()); | 3456 EXPECT_FALSE(sock_->IsConnected()); |
3419 } | 3457 } |
3420 | 3458 |
3421 } // namespace net | 3459 } // namespace net |
OLD | NEW |