| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 EXPECT_EQ("*.webkit.org", dns_names[0]); | 286 EXPECT_EQ("*.webkit.org", dns_names[0]); |
| 287 EXPECT_EQ("webkit.org", dns_names[1]); | 287 EXPECT_EQ("webkit.org", dns_names[1]); |
| 288 | 288 |
| 289 #if TEST_EV | 289 #if TEST_EV |
| 290 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | | 290 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | |
| 291 X509Certificate::VERIFY_EV_CERT; | 291 X509Certificate::VERIFY_EV_CERT; |
| 292 CertVerifyResult verify_result; | 292 CertVerifyResult verify_result; |
| 293 EXPECT_EQ(OK, webkit_cert->Verify("webkit.org", flags, &verify_result)); | 293 EXPECT_EQ(OK, webkit_cert->Verify("webkit.org", flags, &verify_result)); |
| 294 EXPECT_EQ(0, verify_result.cert_status & CERT_STATUS_IS_EV); | 294 EXPECT_EQ(0, verify_result.cert_status & CERT_STATUS_IS_EV); |
| 295 #endif | 295 #endif |
| 296 |
| 297 // Test that the wildcard cert matches properly. |
| 298 EXPECT_TRUE(webkit_cert->VerifyNameMatch("www.webkit.org")); |
| 299 EXPECT_TRUE(webkit_cert->VerifyNameMatch("foo.webkit.org")); |
| 300 EXPECT_TRUE(webkit_cert->VerifyNameMatch("webkit.org")); |
| 301 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.webkit.com")); |
| 302 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.foo.webkit.com")); |
| 296 } | 303 } |
| 297 | 304 |
| 298 TEST(X509CertificateTest, ThawteCertParsing) { | 305 TEST(X509CertificateTest, ThawteCertParsing) { |
| 299 scoped_refptr<X509Certificate> thawte_cert(X509Certificate::CreateFromBytes( | 306 scoped_refptr<X509Certificate> thawte_cert(X509Certificate::CreateFromBytes( |
| 300 reinterpret_cast<const char*>(thawte_der), sizeof(thawte_der))); | 307 reinterpret_cast<const char*>(thawte_der), sizeof(thawte_der))); |
| 301 | 308 |
| 302 ASSERT_NE(static_cast<X509Certificate*>(NULL), thawte_cert); | 309 ASSERT_NE(static_cast<X509Certificate*>(NULL), thawte_cert); |
| 303 | 310 |
| 304 const CertPrincipal& subject = thawte_cert->subject(); | 311 const CertPrincipal& subject = thawte_cert->subject(); |
| 305 EXPECT_EQ("www.thawte.com", subject.common_name); | 312 EXPECT_EQ("www.thawte.com", subject.common_name); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 | 831 |
| 825 for (size_t j = 0; j < 20; ++j) | 832 for (size_t j = 0; j < 20; ++j) |
| 826 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); | 833 EXPECT_EQ(expected_fingerprint[j], actual_fingerprint.data[j]); |
| 827 } | 834 } |
| 828 } | 835 } |
| 829 | 836 |
| 830 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, | 837 INSTANTIATE_TEST_CASE_P(, X509CertificateParseTest, |
| 831 testing::ValuesIn(FormatTestData)); | 838 testing::ValuesIn(FormatTestData)); |
| 832 | 839 |
| 833 } // namespace net | 840 } // namespace net |
| OLD | NEW |