OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); | 368 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV); |
369 // Consequently, if we don't have revocation checking enabled, we can't claim | 369 // Consequently, if we don't have revocation checking enabled, we can't claim |
370 // any cert is EV. | 370 // any cert is EV. |
371 flags = X509Certificate::VERIFY_EV_CERT; | 371 flags = X509Certificate::VERIFY_EV_CERT; |
372 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, NULL, | 372 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, NULL, |
373 &verify_result)); | 373 &verify_result)); |
374 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_IS_EV); | 374 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_IS_EV); |
375 #endif | 375 #endif |
376 } | 376 } |
377 | 377 |
| 378 // Test that all desired AttributeAndValue pairs can be extracted when only |
| 379 // a single RelativeDistinguishedName is present. "Normally" there is only |
| 380 // one AVA per RDN, but some CAs place all AVAs within a single RDN. |
| 381 // This is a regression test for http://crbug.com/101009 |
| 382 TEST(X509CertificateTest, MultivalueRDN) { |
| 383 FilePath certs_dir = GetTestCertsDirectory(); |
| 384 |
| 385 scoped_refptr<X509Certificate> multivalue_rdn_cert = |
| 386 ImportCertFromFile(certs_dir, "multivalue_rdn.pem"); |
| 387 ASSERT_NE(static_cast<X509Certificate*>(NULL), multivalue_rdn_cert); |
| 388 |
| 389 const CertPrincipal& subject = multivalue_rdn_cert->subject(); |
| 390 EXPECT_EQ("Multivalue RDN Test", subject.common_name); |
| 391 EXPECT_EQ("", subject.locality_name); |
| 392 EXPECT_EQ("", subject.state_or_province_name); |
| 393 EXPECT_EQ("US", subject.country_name); |
| 394 EXPECT_EQ(0U, subject.street_addresses.size()); |
| 395 ASSERT_EQ(1U, subject.organization_names.size()); |
| 396 EXPECT_EQ("Chromium", subject.organization_names[0]); |
| 397 ASSERT_EQ(1U, subject.organization_unit_names.size()); |
| 398 EXPECT_EQ("Chromium net_unittests", subject.organization_unit_names[0]); |
| 399 ASSERT_EQ(1U, subject.domain_components.size()); |
| 400 EXPECT_EQ("Chromium", subject.domain_components[0]); |
| 401 } |
| 402 |
| 403 // Test that characters which would normally be escaped in the string form, |
| 404 // such as '=' or '"', are not escaped when parsed as individual components. |
| 405 // This is a regression test for http://crbug.com/102839 |
| 406 TEST(X509CertificateTest, UnescapedSpecialCharacters) { |
| 407 FilePath certs_dir = GetTestCertsDirectory(); |
| 408 |
| 409 scoped_refptr<X509Certificate> unescaped_cert = |
| 410 ImportCertFromFile(certs_dir, "unescaped.pem"); |
| 411 ASSERT_NE(static_cast<X509Certificate*>(NULL), unescaped_cert); |
| 412 |
| 413 const CertPrincipal& subject = unescaped_cert->subject(); |
| 414 EXPECT_EQ("127.0.0.1", subject.common_name); |
| 415 EXPECT_EQ("Mountain View", subject.locality_name); |
| 416 EXPECT_EQ("California", subject.state_or_province_name); |
| 417 EXPECT_EQ("US", subject.country_name); |
| 418 ASSERT_EQ(1U, subject.street_addresses.size()); |
| 419 EXPECT_EQ("1600 Amphitheatre Parkway", subject.street_addresses[0]); |
| 420 ASSERT_EQ(1U, subject.organization_names.size()); |
| 421 EXPECT_EQ("Chromium = \"net_unittests\"", subject.organization_names[0]); |
| 422 ASSERT_EQ(2U, subject.organization_unit_names.size()); |
| 423 EXPECT_EQ("net_unittests", subject.organization_unit_names[0]); |
| 424 EXPECT_EQ("Chromium", subject.organization_unit_names[1]); |
| 425 EXPECT_EQ(0U, subject.domain_components.size()); |
| 426 } |
| 427 |
378 TEST(X509CertificateTest, PaypalNullCertParsing) { | 428 TEST(X509CertificateTest, PaypalNullCertParsing) { |
379 scoped_refptr<X509Certificate> paypal_null_cert( | 429 scoped_refptr<X509Certificate> paypal_null_cert( |
380 X509Certificate::CreateFromBytes( | 430 X509Certificate::CreateFromBytes( |
381 reinterpret_cast<const char*>(paypal_null_der), | 431 reinterpret_cast<const char*>(paypal_null_der), |
382 sizeof(paypal_null_der))); | 432 sizeof(paypal_null_der))); |
383 | 433 |
384 ASSERT_NE(static_cast<X509Certificate*>(NULL), paypal_null_cert); | 434 ASSERT_NE(static_cast<X509Certificate*>(NULL), paypal_null_cert); |
385 | 435 |
386 const SHA1Fingerprint& fingerprint = | 436 const SHA1Fingerprint& fingerprint = |
387 paypal_null_cert->fingerprint(); | 437 paypal_null_cert->fingerprint(); |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 #define MAYBE_VerifyMixed DISABLED_VerifyMixed | 1751 #define MAYBE_VerifyMixed DISABLED_VerifyMixed |
1702 #else | 1752 #else |
1703 #define MAYBE_VerifyMixed VerifyMixed | 1753 #define MAYBE_VerifyMixed VerifyMixed |
1704 #endif | 1754 #endif |
1705 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1755 WRAPPED_INSTANTIATE_TEST_CASE_P( |
1706 MAYBE_VerifyMixed, | 1756 MAYBE_VerifyMixed, |
1707 X509CertificateWeakDigestTest, | 1757 X509CertificateWeakDigestTest, |
1708 testing::ValuesIn(kVerifyMixedTestData)); | 1758 testing::ValuesIn(kVerifyMixedTestData)); |
1709 | 1759 |
1710 } // namespace net | 1760 } // namespace net |
OLD | NEW |