OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/crypto/rsa_private_key.h" | 5 #include "base/crypto/rsa_private_key.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "net/base/cert_status_flags.h" | 10 #include "net/base/cert_status_flags.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 std::vector<CertPrincipal> both_issuers; | 652 std::vector<CertPrincipal> both_issuers; |
653 both_issuers.push_back(mit_issuer); | 653 both_issuers.push_back(mit_issuer); |
654 both_issuers.push_back(foaf_issuer); | 654 both_issuers.push_back(foaf_issuer); |
655 EXPECT_TRUE(foaf_me_chromium_test_cert->IsIssuedBy(both_issuers)); | 655 EXPECT_TRUE(foaf_me_chromium_test_cert->IsIssuedBy(both_issuers)); |
656 EXPECT_TRUE(mit_davidben_cert->IsIssuedBy(both_issuers)); | 656 EXPECT_TRUE(mit_davidben_cert->IsIssuedBy(both_issuers)); |
657 EXPECT_FALSE(foaf_me_chromium_test_cert->IsIssuedBy(mit_issuers)); | 657 EXPECT_FALSE(foaf_me_chromium_test_cert->IsIssuedBy(mit_issuers)); |
658 EXPECT_FALSE(mit_davidben_cert->IsIssuedBy(foaf_issuers)); | 658 EXPECT_FALSE(mit_davidben_cert->IsIssuedBy(foaf_issuers)); |
659 } | 659 } |
660 #endif // defined(OS_MACOSX) | 660 #endif // defined(OS_MACOSX) |
661 | 661 |
662 #if defined(USE_NSS) || defined(OS_WIN) | 662 #if defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX) |
663 // This test creates a self-signed cert from a private key and then verify the | 663 // This test creates a self-signed cert from a private key and then verify the |
664 // content of the certificate. | 664 // content of the certificate. |
665 TEST(X509CertificateTest, CreateSelfSigned) { | 665 TEST(X509CertificateTest, CreateSelfSigned) { |
666 scoped_ptr<base::RSAPrivateKey> private_key( | 666 scoped_ptr<base::RSAPrivateKey> private_key( |
667 base::RSAPrivateKey::Create(1024)); | 667 base::RSAPrivateKey::Create(1024)); |
668 scoped_refptr<net::X509Certificate> cert = | 668 scoped_refptr<net::X509Certificate> cert = |
669 net::X509Certificate::CreateSelfSigned( | 669 net::X509Certificate::CreateSelfSigned( |
670 private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); | 670 private_key.get(), "CN=subject", 1, base::TimeDelta::FromDays(1)); |
671 | 671 |
672 EXPECT_EQ("subject", cert->subject().GetDisplayName()); | 672 EXPECT_EQ("subject", cert->subject().GetDisplayName()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 728 |
729 for (size_t j = 0; j < 20; ++j) | 729 for (size_t j = 0; j < 20; ++j) |
730 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); | 730 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, | 734 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, |
735 testing::ValuesIn(FormatTestData)); | 735 testing::ValuesIn(FormatTestData)); |
736 | 736 |
737 } // namespace net | 737 } // namespace net |
OLD | NEW |