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

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

Issue 12220104: Wire up SSL client authentication for OpenSSL/Android through the net/ stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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
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 "net/base/address_list.h" 9 #include "net/base/address_list.h"
10 #include "net/base/cert_test_util.h" 10 #include "net/base/cert_test_util.h"
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 if (rv == net::ERR_IO_PENDING) 1223 if (rv == net::ERR_IO_PENDING)
1224 rv = callback.WaitForResult(); 1224 rv = callback.WaitForResult();
1225 scoped_refptr<net::SSLCertRequestInfo> request_info = 1225 scoped_refptr<net::SSLCertRequestInfo> request_info =
1226 new net::SSLCertRequestInfo(); 1226 new net::SSLCertRequestInfo();
1227 sock->GetSSLCertRequestInfo(request_info.get()); 1227 sock->GetSSLCertRequestInfo(request_info.get());
1228 sock->Disconnect(); 1228 sock->Disconnect();
1229 EXPECT_FALSE(sock->IsConnected()); 1229 EXPECT_FALSE(sock->IsConnected());
1230 1230
1231 return request_info; 1231 return request_info;
1232 } 1232 }
1233
1234 // The following is needed to construct paths to certificates passed as
1235 // |client_authorities| in server SSLOptions. Current implementation of
1236 // RemoteTestServer (used on Android) expects relative paths, as opposed to
1237 // LocalTestServer, which expects absolute paths (what to fix?).
1238 base::FilePath CertDirectory() {
1239 #ifdef OS_ANDROID
1240 return net::GetTestCertsDirectoryRelative();
1241 #else
1242 return net::GetTestCertsDirectory();
1243 #endif
1244 }
1245 }; 1233 };
1246 1234
1247 TEST_F(SSLClientSocketCertRequestInfoTest, NoAuthorities) { 1235 TEST_F(SSLClientSocketCertRequestInfoTest, NoAuthorities) {
1248 net::TestServer::SSLOptions ssl_options; 1236 net::TestServer::SSLOptions ssl_options;
1249 ssl_options.request_client_certificate = true; 1237 ssl_options.request_client_certificate = true;
1250 scoped_refptr<net::SSLCertRequestInfo> request_info = 1238 scoped_refptr<net::SSLCertRequestInfo> request_info =
1251 GetCertRequest(ssl_options); 1239 GetCertRequest(ssl_options);
1252 ASSERT_TRUE(request_info); 1240 ASSERT_TRUE(request_info);
1253 EXPECT_EQ(0u, request_info->cert_authorities.size()); 1241 EXPECT_EQ(0u, request_info->cert_authorities.size());
1254 } 1242 }
(...skipping 22 matching lines...) Expand all
1277 0x67, 0x69, 0x4e, 0x6f, 0x74, 0x61, 0x72, 0x20, 0x52, 0x6f, 0x6f, 0x74, 1265 0x67, 0x69, 0x4e, 0x6f, 0x74, 0x61, 0x72, 0x20, 0x52, 0x6f, 0x6f, 0x74,
1278 0x20, 0x43, 0x41, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48, 1266 0x20, 0x43, 0x41, 0x31, 0x20, 0x30, 0x1e, 0x06, 0x09, 0x2a, 0x86, 0x48,
1279 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x11, 0x69, 0x6e, 0x66, 0x6f, 1267 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x11, 0x69, 0x6e, 0x66, 0x6f,
1280 0x40, 0x64, 0x69, 0x67, 0x69, 0x6e, 0x6f, 0x74, 0x61, 0x72, 0x2e, 0x6e, 1268 0x40, 0x64, 0x69, 0x67, 0x69, 0x6e, 0x6f, 0x74, 0x61, 0x72, 0x2e, 0x6e,
1281 0x6c 1269 0x6c
1282 }; 1270 };
1283 const size_t kDiginotarLen = sizeof(kDiginotarDN); 1271 const size_t kDiginotarLen = sizeof(kDiginotarDN);
1284 1272
1285 net::TestServer::SSLOptions ssl_options; 1273 net::TestServer::SSLOptions ssl_options;
1286 ssl_options.request_client_certificate = true; 1274 ssl_options.request_client_certificate = true;
1287 ssl_options.client_authorities.push_back(CertDirectory().Append(kThawteFile));
1288 ssl_options.client_authorities.push_back( 1275 ssl_options.client_authorities.push_back(
1289 CertDirectory().Append(kDiginotarFile)); 1276 net::GetTestClientCertsDirectory().Append(kThawteFile));
1277 ssl_options.client_authorities.push_back(
1278 net::GetTestClientCertsDirectory().Append(kDiginotarFile));
1290 scoped_refptr<net::SSLCertRequestInfo> request_info = 1279 scoped_refptr<net::SSLCertRequestInfo> request_info =
1291 GetCertRequest(ssl_options); 1280 GetCertRequest(ssl_options);
1292 ASSERT_TRUE(request_info); 1281 ASSERT_TRUE(request_info);
1293 ASSERT_EQ(2u, request_info->cert_authorities.size()); 1282 ASSERT_EQ(2u, request_info->cert_authorities.size());
1294 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen), 1283 EXPECT_EQ(std::string(reinterpret_cast<const char*>(kThawteDN), kThawteLen),
1295 request_info->cert_authorities[0]); 1284 request_info->cert_authorities[0]);
1296 EXPECT_EQ( 1285 EXPECT_EQ(
1297 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen), 1286 std::string(reinterpret_cast<const char*>(kDiginotarDN), kDiginotarLen),
1298 request_info->cert_authorities[1]); 1287 request_info->cert_authorities[1]);
1299 } 1288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698