Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 257513008: Populate cert_key_types on OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USE_OPENSSL_CERTS Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "net/base/address_list.h" 10 #include "net/base/address_list.h"
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig)); 614 transport.Pass(), test_server.host_port_pair(), kDefaultSSLConfig));
615 EXPECT_FALSE(sock->IsConnected()); 615 EXPECT_FALSE(sock->IsConnected());
616 616
617 rv = sock->Connect(callback.callback()); 617 rv = sock->Connect(callback.callback());
618 if (rv == ERR_IO_PENDING) 618 if (rv == ERR_IO_PENDING)
619 rv = callback.WaitForResult(); 619 rv = callback.WaitForResult();
620 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo(); 620 scoped_refptr<SSLCertRequestInfo> request_info = new SSLCertRequestInfo();
621 sock->GetSSLCertRequestInfo(request_info.get()); 621 sock->GetSSLCertRequestInfo(request_info.get());
622 sock->Disconnect(); 622 sock->Disconnect();
623 EXPECT_FALSE(sock->IsConnected()); 623 EXPECT_FALSE(sock->IsConnected());
624 EXPECT_TRUE(
625 test_server.host_port_pair().Equals(request_info->host_and_port));
624 626
625 return request_info; 627 return request_info;
626 } 628 }
627 }; 629 };
628 630
629 class SSLClientSocketFalseStartTest : public SSLClientSocketTest { 631 class SSLClientSocketFalseStartTest : public SSLClientSocketTest {
630 protected: 632 protected:
631 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options, 633 void TestFalseStart(const SpawnedTestServer::SSLOptions& server_options,
632 const SSLConfig& client_config, 634 const SSLConfig& client_config,
633 bool expect_false_start) { 635 bool expect_false_start) {
(...skipping 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options); 2112 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options);
2111 ASSERT_TRUE(request_info.get()); 2113 ASSERT_TRUE(request_info.get());
2112 ASSERT_EQ(2u, request_info->cert_authorities.size()); 2114 ASSERT_EQ(2u, request_info->cert_authorities.size());
2113 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), 2115 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen),
2114 request_info->cert_authorities[0]); 2116 request_info->cert_authorities[0]);
2115 EXPECT_EQ( 2117 EXPECT_EQ(
2116 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), 2118 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen),
2117 request_info->cert_authorities[1]); 2119 request_info->cert_authorities[1]);
2118 } 2120 }
2119 2121
2122 // client_key_types is only populated on OpenSSL and currently only when
wtc 2014/04/25 18:52:40 1. Typo: client_key_types => cert_key_types 2. We
davidben 2014/04/25 20:52:31 Done.
wtc 2014/04/26 12:36:04 SSL_GetRequestedClientCertificateTypes was used be
2123 // USE_OPENSSL_CERTS is defined.
2124 #if defined(USE_OPENSSL) && defined(USE_OPENSSL_CERTS)
2125 TEST_F(SSLClientSocketCertRequestInfoTest, ClientKeyTypes) {
wtc 2014/04/25 18:52:40 Nit: ClientKeyTypes => CertKeyTypes or ClientCertK
davidben 2014/04/25 20:52:31 Done.
2126 SpawnedTestServer::SSLOptions ssl_options;
2127 ssl_options.request_client_certificate = true;
2128 ssl_options.client_cert_types.push_back(CLIENT_CERT_RSA_SIGN);
2129 ssl_options.client_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN);
2130 scoped_refptr<SSLCertRequestInfo> request_info = GetCertRequest(ssl_options);
2131 ASSERT_TRUE(request_info.get());
2132 ASSERT_EQ(2u, request_info->cert_key_types.size());
2133 EXPECT_EQ(CLIENT_CERT_RSA_SIGN, request_info->cert_key_types[0]);
2134 EXPECT_EQ(CLIENT_CERT_ECDSA_SIGN, request_info->cert_key_types[1]);
2135 }
2136 #endif
2137
2120 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) { 2138 TEST_F(SSLClientSocketTest, ConnectSignedCertTimestampsEnabledTLSExtension) {
2121 SpawnedTestServer::SSLOptions ssl_options; 2139 SpawnedTestServer::SSLOptions ssl_options;
2122 ssl_options.signed_cert_timestamps_tls_ext = "test"; 2140 ssl_options.signed_cert_timestamps_tls_ext = "test";
2123 2141
2124 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, 2142 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
2125 ssl_options, 2143 ssl_options,
2126 base::FilePath()); 2144 base::FilePath());
2127 ASSERT_TRUE(test_server.Start()); 2145 ASSERT_TRUE(test_server.Start());
2128 2146
2129 AddressList addr; 2147 AddressList addr;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 SpawnedTestServer::SSLOptions server_options; 2375 SpawnedTestServer::SSLOptions server_options;
2358 server_options.key_exchanges = 2376 server_options.key_exchanges =
2359 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_RSA; 2377 SpawnedTestServer::SSLOptions::KEY_EXCHANGE_RSA;
2360 server_options.enable_npn = true; 2378 server_options.enable_npn = true;
2361 SSLConfig client_config; 2379 SSLConfig client_config;
2362 client_config.next_protos.push_back("http/1.1"); 2380 client_config.next_protos.push_back("http/1.1");
2363 TestFalseStart(server_options, client_config, false); 2381 TestFalseStart(server_options, client_config, false);
2364 } 2382 }
2365 2383
2366 } // namespace net 2384 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698