| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <queue> | 18 #include <queue> |
| 19 | 19 |
| 20 #include "base/crypto/rsa_private_key.h" | |
| 21 #include "base/file_path.h" | 20 #include "base/file_path.h" |
| 22 #include "base/file_util.h" | 21 #include "base/file_util.h" |
| 23 #include "base/nss_util.h" | |
| 24 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "crypto/nss_util.h" |
| 24 #include "crypto/rsa_private_key.h" |
| 25 #include "net/base/address_list.h" | 25 #include "net/base/address_list.h" |
| 26 #include "net/base/cert_status_flags.h" | 26 #include "net/base/cert_status_flags.h" |
| 27 #include "net/base/cert_verifier.h" | 27 #include "net/base/cert_verifier.h" |
| 28 #include "net/base/host_port_pair.h" | 28 #include "net/base/host_port_pair.h" |
| 29 #include "net/base/io_buffer.h" | 29 #include "net/base/io_buffer.h" |
| 30 #include "net/base/net_errors.h" | 30 #include "net/base/net_errors.h" |
| 31 #include "net/base/net_log.h" | 31 #include "net/base/net_log.h" |
| 32 #include "net/base/ssl_config_service.h" | 32 #include "net/base/ssl_config_service.h" |
| 33 #include "net/base/x509_certificate.h" | 33 #include "net/base/x509_certificate.h" |
| 34 #include "net/socket/client_socket.h" | 34 #include "net/socket/client_socket.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size()); | 227 X509Certificate::CreateFromBytes(cert_der.data(), cert_der.size()); |
| 228 | 228 |
| 229 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 229 FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
| 230 std::string key_string; | 230 std::string key_string; |
| 231 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); | 231 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); |
| 232 std::vector<uint8> key_vector( | 232 std::vector<uint8> key_vector( |
| 233 reinterpret_cast<const uint8*>(key_string.data()), | 233 reinterpret_cast<const uint8*>(key_string.data()), |
| 234 reinterpret_cast<const uint8*>(key_string.data() + | 234 reinterpret_cast<const uint8*>(key_string.data() + |
| 235 key_string.length())); | 235 key_string.length())); |
| 236 | 236 |
| 237 scoped_ptr<base::RSAPrivateKey> private_key( | 237 scoped_ptr<crypto::RSAPrivateKey> private_key( |
| 238 base::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector)); | 238 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector)); |
| 239 | 239 |
| 240 net::SSLConfig ssl_config; | 240 net::SSLConfig ssl_config; |
| 241 ssl_config.false_start_enabled = false; | 241 ssl_config.false_start_enabled = false; |
| 242 ssl_config.ssl3_enabled = true; | 242 ssl_config.ssl3_enabled = true; |
| 243 ssl_config.tls1_enabled = true; | 243 ssl_config.tls1_enabled = true; |
| 244 | 244 |
| 245 // Certificate provided by the host doesn't need authority. | 245 // Certificate provided by the host doesn't need authority. |
| 246 net::SSLConfig::CertAndStatus cert_and_status; | 246 net::SSLConfig::CertAndStatus cert_and_status; |
| 247 cert_and_status.cert_status = net::CERT_STATUS_AUTHORITY_INVALID; | 247 cert_and_status.cert_status = net::CERT_STATUS_AUTHORITY_INVALID; |
| 248 cert_and_status.cert = cert; | 248 cert_and_status.cert = cert; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 EXPECT_GT(read_callback.WaitForResult(), 0); | 353 EXPECT_GT(read_callback.WaitForResult(), 0); |
| 354 } | 354 } |
| 355 if (client_ret == net::ERR_IO_PENDING) { | 355 if (client_ret == net::ERR_IO_PENDING) { |
| 356 EXPECT_GT(write_callback.WaitForResult(), 0); | 356 EXPECT_GT(write_callback.WaitForResult(), 0); |
| 357 } | 357 } |
| 358 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size())); | 358 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size())); |
| 359 } | 359 } |
| 360 #endif | 360 #endif |
| 361 | 361 |
| 362 } // namespace net | 362 } // namespace net |
| OLD | NEW |