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 // This test suite uses SSLClientSocket to test the implementation of | 5 // This test suite uses SSLClientSocket to test the implementation of |
6 // SSLServerSocket. In order to establish connections between the sockets | 6 // SSLServerSocket. In order to establish connections between the sockets |
7 // we need two additional classes: | 7 // we need two additional classes: |
8 // 1. FakeSocket | 8 // 1. FakeSocket |
9 // Connects SSL socket to FakeDataChannel. This class is just a stub. | 9 // Connects SSL socket to FakeDataChannel. This class is just a stub. |
10 // | 10 // |
11 // 2. FakeDataChannel | 11 // 2. FakeDataChannel |
12 // Implements the actual exchange of data between two FakeSockets. | 12 // Implements the actual exchange of data between two FakeSockets. |
13 // | 13 // |
14 // Implementations of these two classes are included in this file. | 14 // Implementations of these two classes are included in this file. |
15 | 15 |
16 #include "net/socket/ssl_server_socket.h" | 16 #include "net/socket/ssl_server_socket.h" |
17 | 17 |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 #include <stdlib.h> | 19 #include <stdlib.h> |
20 | |
21 #include <queue> | 20 #include <queue> |
| 21 #include <utility> |
22 | 22 |
23 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
24 #include "base/files/file_path.h" | 24 #include "base/files/file_path.h" |
25 #include "base/files/file_util.h" | 25 #include "base/files/file_util.h" |
26 #include "base/location.h" | 26 #include "base/location.h" |
27 #include "base/logging.h" | 27 #include "base/logging.h" |
28 #include "base/macros.h" | 28 #include "base/macros.h" |
29 #include "base/message_loop/message_loop.h" | 29 #include "base/message_loop/message_loop.h" |
30 #include "base/single_thread_task_runner.h" | 30 #include "base/single_thread_task_runner.h" |
31 #include "base/thread_task_runner_handle.h" | 31 #include "base/thread_task_runner_handle.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 SSLConfig::CertAndStatus cert_and_status; | 341 SSLConfig::CertAndStatus cert_and_status; |
342 cert_and_status.cert_status = CERT_STATUS_AUTHORITY_INVALID; | 342 cert_and_status.cert_status = CERT_STATUS_AUTHORITY_INVALID; |
343 cert_and_status.der_cert = cert_der; | 343 cert_and_status.der_cert = cert_der; |
344 client_ssl_config_.allowed_bad_certs.push_back(cert_and_status); | 344 client_ssl_config_.allowed_bad_certs.push_back(cert_and_status); |
345 | 345 |
346 HostPortPair host_and_pair("unittest", 0); | 346 HostPortPair host_and_pair("unittest", 0); |
347 SSLClientSocketContext context; | 347 SSLClientSocketContext context; |
348 context.cert_verifier = cert_verifier_.get(); | 348 context.cert_verifier = cert_verifier_.get(); |
349 context.transport_security_state = transport_security_state_.get(); | 349 context.transport_security_state = transport_security_state_.get(); |
350 client_socket_ = socket_factory_->CreateSSLClientSocket( | 350 client_socket_ = socket_factory_->CreateSSLClientSocket( |
351 client_connection.Pass(), host_and_pair, client_ssl_config_, context); | 351 std::move(client_connection), host_and_pair, client_ssl_config_, |
| 352 context); |
352 server_socket_ = | 353 server_socket_ = |
353 CreateSSLServerSocket(server_socket.Pass(), cert.get(), | 354 CreateSSLServerSocket(std::move(server_socket), cert.get(), |
354 private_key.get(), server_ssl_config_); | 355 private_key.get(), server_ssl_config_); |
355 } | 356 } |
356 | 357 |
357 FakeDataChannel channel_1_; | 358 FakeDataChannel channel_1_; |
358 FakeDataChannel channel_2_; | 359 FakeDataChannel channel_2_; |
359 SSLConfig client_ssl_config_; | 360 SSLConfig client_ssl_config_; |
360 SSLServerConfig server_ssl_config_; | 361 SSLServerConfig server_ssl_config_; |
361 scoped_ptr<SSLClientSocket> client_socket_; | 362 scoped_ptr<SSLClientSocket> client_socket_; |
362 scoped_ptr<SSLServerSocket> server_socket_; | 363 scoped_ptr<SSLServerSocket> server_socket_; |
363 ClientSocketFactory* socket_factory_; | 364 ClientSocketFactory* socket_factory_; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 int server_ret = server_socket_->Handshake(handshake_callback.callback()); | 623 int server_ret = server_socket_->Handshake(handshake_callback.callback()); |
623 | 624 |
624 client_ret = connect_callback.GetResult(client_ret); | 625 client_ret = connect_callback.GetResult(client_ret); |
625 server_ret = handshake_callback.GetResult(server_ret); | 626 server_ret = handshake_callback.GetResult(server_ret); |
626 | 627 |
627 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, client_ret); | 628 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, client_ret); |
628 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, server_ret); | 629 ASSERT_EQ(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, server_ret); |
629 } | 630 } |
630 | 631 |
631 } // namespace net | 632 } // namespace net |
OLD | NEW |