OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chromeos/network/client_cert_resolver.h" | 4 #include "chromeos/network/client_cert_resolver.h" |
5 | 5 |
6 #include <cert.h> | 6 #include <cert.h> |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 ca_cert_list, net::NSSCertDatabase::TRUST_DEFAULT, &failures)); | 97 ca_cert_list, net::NSSCertDatabase::TRUST_DEFAULT, &failures)); |
98 ASSERT_TRUE(failures.empty()) << net::ErrorToString(failures[0].net_error); | 98 ASSERT_TRUE(failures.empty()) << net::ErrorToString(failures[0].net_error); |
99 | 99 |
100 net::X509Certificate::GetPEMEncoded(ca_cert_list[0]->os_cert_handle(), | 100 net::X509Certificate::GetPEMEncoded(ca_cert_list[0]->os_cert_handle(), |
101 &test_ca_cert_pem_); | 101 &test_ca_cert_pem_); |
102 ASSERT_TRUE(!test_ca_cert_pem_.empty()); | 102 ASSERT_TRUE(!test_ca_cert_pem_.empty()); |
103 | 103 |
104 // Import a client cert signed by that CA. | 104 // Import a client cert signed by that CA. |
105 scoped_refptr<net::CryptoModule> crypt_module = cert_db->GetPrivateModule(); | 105 scoped_refptr<net::CryptoModule> crypt_module = cert_db->GetPrivateModule(); |
106 std::string pkcs12_data; | 106 std::string pkcs12_data; |
107 ASSERT_TRUE(file_util::ReadFileToString( | 107 ASSERT_TRUE(base::ReadFileToString( |
108 net::GetTestCertsDirectory().Append("websocket_client_cert.p12"), | 108 net::GetTestCertsDirectory().Append("websocket_client_cert.p12"), |
109 &pkcs12_data)); | 109 &pkcs12_data)); |
110 | 110 |
111 net::CertificateList client_cert_list; | 111 net::CertificateList client_cert_list; |
112 ASSERT_EQ(net::OK, | 112 ASSERT_EQ(net::OK, |
113 cert_db->ImportFromPKCS12(crypt_module.get(), | 113 cert_db->ImportFromPKCS12(crypt_module.get(), |
114 pkcs12_data, | 114 pkcs12_data, |
115 string16(), | 115 string16(), |
116 false, | 116 false, |
117 &client_cert_list)); | 117 &client_cert_list)); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 message_loop_.RunUntilIdle(); | 272 message_loop_.RunUntilIdle(); |
273 | 273 |
274 // Verify that the resolver positively matched the pattern in the policy with | 274 // Verify that the resolver positively matched the pattern in the policy with |
275 // the test client cert and configured the network. | 275 // the test client cert and configured the network. |
276 std::string pkcs11_id; | 276 std::string pkcs11_id; |
277 GetClientCertProperties(&pkcs11_id); | 277 GetClientCertProperties(&pkcs11_id); |
278 EXPECT_EQ(test_pkcs11_id_, pkcs11_id); | 278 EXPECT_EQ(test_pkcs11_id_, pkcs11_id); |
279 } | 279 } |
280 | 280 |
281 } // namespace chromeos | 281 } // namespace chromeos |
OLD | NEW |