| 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 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "base/location.h" | 31 #include "base/location.h" |
| 32 #include "base/logging.h" | 32 #include "base/logging.h" |
| 33 #include "base/macros.h" | 33 #include "base/macros.h" |
| 34 #include "base/message_loop/message_loop.h" | 34 #include "base/message_loop/message_loop.h" |
| 35 #include "base/run_loop.h" | 35 #include "base/run_loop.h" |
| 36 #include "base/single_thread_task_runner.h" | 36 #include "base/single_thread_task_runner.h" |
| 37 #include "base/threading/thread_task_runner_handle.h" | 37 #include "base/threading/thread_task_runner_handle.h" |
| 38 #include "build/build_config.h" | 38 #include "build/build_config.h" |
| 39 #include "crypto/nss_util.h" | 39 #include "crypto/nss_util.h" |
| 40 #include "crypto/rsa_private_key.h" | 40 #include "crypto/rsa_private_key.h" |
| 41 #include "crypto/scoped_openssl_types.h" | |
| 42 #include "crypto/signature_creator.h" | 41 #include "crypto/signature_creator.h" |
| 43 #include "net/base/address_list.h" | 42 #include "net/base/address_list.h" |
| 44 #include "net/base/completion_callback.h" | 43 #include "net/base/completion_callback.h" |
| 45 #include "net/base/host_port_pair.h" | 44 #include "net/base/host_port_pair.h" |
| 46 #include "net/base/io_buffer.h" | 45 #include "net/base/io_buffer.h" |
| 47 #include "net/base/ip_address.h" | 46 #include "net/base/ip_address.h" |
| 48 #include "net/base/ip_endpoint.h" | 47 #include "net/base/ip_endpoint.h" |
| 49 #include "net/base/net_errors.h" | 48 #include "net/base/net_errors.h" |
| 50 #include "net/cert/cert_status_flags.h" | 49 #include "net/cert/cert_status_flags.h" |
| 51 #include "net/cert/ct_policy_enforcer.h" | 50 #include "net/cert/ct_policy_enforcer.h" |
| 52 #include "net/cert/ct_policy_status.h" | 51 #include "net/cert/ct_policy_status.h" |
| 53 #include "net/cert/ct_verifier.h" | 52 #include "net/cert/ct_verifier.h" |
| 54 #include "net/cert/mock_cert_verifier.h" | 53 #include "net/cert/mock_cert_verifier.h" |
| 55 #include "net/cert/mock_client_cert_verifier.h" | 54 #include "net/cert/mock_client_cert_verifier.h" |
| 56 #include "net/cert/x509_certificate.h" | 55 #include "net/cert/x509_certificate.h" |
| 57 #include "net/http/transport_security_state.h" | 56 #include "net/http/transport_security_state.h" |
| 58 #include "net/log/net_log_with_source.h" | 57 #include "net/log/net_log_with_source.h" |
| 59 #include "net/socket/client_socket_factory.h" | 58 #include "net/socket/client_socket_factory.h" |
| 60 #include "net/socket/socket_test_util.h" | 59 #include "net/socket/socket_test_util.h" |
| 61 #include "net/socket/ssl_client_socket.h" | 60 #include "net/socket/ssl_client_socket.h" |
| 62 #include "net/socket/stream_socket.h" | 61 #include "net/socket/stream_socket.h" |
| 63 #include "net/ssl/scoped_openssl_types.h" | |
| 64 #include "net/ssl/ssl_cert_request_info.h" | 62 #include "net/ssl/ssl_cert_request_info.h" |
| 65 #include "net/ssl/ssl_cipher_suite_names.h" | 63 #include "net/ssl/ssl_cipher_suite_names.h" |
| 66 #include "net/ssl/ssl_connection_status_flags.h" | 64 #include "net/ssl/ssl_connection_status_flags.h" |
| 67 #include "net/ssl/ssl_info.h" | 65 #include "net/ssl/ssl_info.h" |
| 68 #include "net/ssl/ssl_private_key.h" | 66 #include "net/ssl/ssl_private_key.h" |
| 69 #include "net/ssl/ssl_server_config.h" | 67 #include "net/ssl/ssl_server_config.h" |
| 70 #include "net/ssl/test_ssl_private_key.h" | 68 #include "net/ssl/test_ssl_private_key.h" |
| 71 #include "net/test/cert_test_util.h" | 69 #include "net/test/cert_test_util.h" |
| 72 #include "net/test/gtest_util.h" | 70 #include "net/test/gtest_util.h" |
| 73 #include "net/test/test_data_directory.h" | 71 #include "net/test/test_data_directory.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 client_ssl_config_.client_cert = | 443 client_ssl_config_.client_cert = |
| 446 ImportCertFromFile(GetTestCertsDirectory(), cert_file_name); | 444 ImportCertFromFile(GetTestCertsDirectory(), cert_file_name); |
| 447 ASSERT_TRUE(client_ssl_config_.client_cert); | 445 ASSERT_TRUE(client_ssl_config_.client_cert); |
| 448 | 446 |
| 449 std::unique_ptr<crypto::RSAPrivateKey> key = | 447 std::unique_ptr<crypto::RSAPrivateKey> key = |
| 450 ReadTestKey(private_key_file_name); | 448 ReadTestKey(private_key_file_name); |
| 451 ASSERT_TRUE(key); | 449 ASSERT_TRUE(key); |
| 452 | 450 |
| 453 EVP_PKEY_up_ref(key->key()); | 451 EVP_PKEY_up_ref(key->key()); |
| 454 client_ssl_config_.client_private_key = | 452 client_ssl_config_.client_private_key = |
| 455 WrapOpenSSLPrivateKey(crypto::ScopedEVP_PKEY(key->key())); | 453 WrapOpenSSLPrivateKey(bssl::UniquePtr<EVP_PKEY>(key->key())); |
| 456 } | 454 } |
| 457 | 455 |
| 458 void ConfigureClientCertsForServer() { | 456 void ConfigureClientCertsForServer() { |
| 459 server_ssl_config_.client_cert_type = | 457 server_ssl_config_.client_cert_type = |
| 460 SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT; | 458 SSLServerConfig::ClientCertType::REQUIRE_CLIENT_CERT; |
| 461 | 459 |
| 462 ScopedX509NameStack cert_names( | 460 bssl::UniquePtr<STACK_OF(X509_NAME)> cert_names( |
| 463 SSL_load_client_CA_file(GetTestCertsDirectory() | 461 SSL_load_client_CA_file(GetTestCertsDirectory() |
| 464 .AppendASCII(kClientCertCAFileName) | 462 .AppendASCII(kClientCertCAFileName) |
| 465 .MaybeAsASCII() | 463 .MaybeAsASCII() |
| 466 .c_str())); | 464 .c_str())); |
| 467 ASSERT_TRUE(cert_names); | 465 ASSERT_TRUE(cert_names); |
| 468 | 466 |
| 469 for (size_t i = 0; i < sk_X509_NAME_num(cert_names.get()); ++i) { | 467 for (size_t i = 0; i < sk_X509_NAME_num(cert_names.get()); ++i) { |
| 470 uint8_t* str = nullptr; | 468 uint8_t* str = nullptr; |
| 471 int length = i2d_X509_NAME(sk_X509_NAME_value(cert_names.get(), i), &str); | 469 int length = i2d_X509_NAME(sk_X509_NAME_value(cert_names.get(), i), &str); |
| 472 ASSERT_LT(0, length); | 470 ASSERT_LT(0, length); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 int server_ret = server_socket_->Handshake(handshake_callback.callback()); | 1111 int server_ret = server_socket_->Handshake(handshake_callback.callback()); |
| 1114 | 1112 |
| 1115 client_ret = connect_callback.GetResult(client_ret); | 1113 client_ret = connect_callback.GetResult(client_ret); |
| 1116 server_ret = handshake_callback.GetResult(server_ret); | 1114 server_ret = handshake_callback.GetResult(server_ret); |
| 1117 | 1115 |
| 1118 ASSERT_THAT(client_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); | 1116 ASSERT_THAT(client_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); |
| 1119 ASSERT_THAT(server_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); | 1117 ASSERT_THAT(server_ret, IsError(ERR_SSL_VERSION_OR_CIPHER_MISMATCH)); |
| 1120 } | 1118 } |
| 1121 | 1119 |
| 1122 } // namespace net | 1120 } // namespace net |
| OLD | NEW |