OLD | NEW |
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/cert/cert_verify_proc.h" | 5 #include "net/cert/cert_verify_proc.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 } | 1689 } |
1690 | 1690 |
1691 class CertVerifyProcWeakDigestTest | 1691 class CertVerifyProcWeakDigestTest |
1692 : public CertVerifyProcTest, | 1692 : public CertVerifyProcTest, |
1693 public testing::WithParamInterface<WeakDigestTestData> { | 1693 public testing::WithParamInterface<WeakDigestTestData> { |
1694 public: | 1694 public: |
1695 CertVerifyProcWeakDigestTest() {} | 1695 CertVerifyProcWeakDigestTest() {} |
1696 virtual ~CertVerifyProcWeakDigestTest() {} | 1696 virtual ~CertVerifyProcWeakDigestTest() {} |
1697 }; | 1697 }; |
1698 | 1698 |
1699 // Test that the underlying cryptographic library properly surfaces the | 1699 // Test that the CertVerifyProc::Verify() properly surfaces the (weak) hashing |
1700 // algorithms used in the chain. Some libraries, like NSS, don't return | 1700 // algorithms used in the chain. |
1701 // the failing chain on error, and thus not all tests can be run. | |
1702 TEST_P(CertVerifyProcWeakDigestTest, VerifyDetectsAlgorithm) { | 1701 TEST_P(CertVerifyProcWeakDigestTest, VerifyDetectsAlgorithm) { |
1703 WeakDigestTestData data = GetParam(); | 1702 WeakDigestTestData data = GetParam(); |
1704 base::FilePath certs_dir = GetTestCertsDirectory(); | 1703 base::FilePath certs_dir = GetTestCertsDirectory(); |
1705 | 1704 |
1706 ScopedTestRoot test_root; | 1705 scoped_refptr<X509Certificate> intermediate_cert; |
1707 if (data.root_cert_filename) { | 1706 scoped_refptr<X509Certificate> root_cert; |
1708 scoped_refptr<X509Certificate> root_cert = | 1707 |
1709 ImportCertFromFile(certs_dir, data.root_cert_filename); | 1708 // Build |intermediates| as the full chain (including trust anchor). |
1710 ASSERT_TRUE(root_cert); | 1709 X509Certificate::OSCertHandles intermediates; |
1711 test_root.Reset(root_cert.get()); | 1710 |
| 1711 if (data.intermediate_cert_filename) { |
| 1712 intermediate_cert = |
| 1713 ImportCertFromFile(certs_dir, data.intermediate_cert_filename); |
| 1714 ASSERT_TRUE(intermediate_cert); |
| 1715 intermediates.push_back(intermediate_cert->os_cert_handle()); |
1712 } | 1716 } |
1713 | 1717 |
1714 scoped_refptr<X509Certificate> intermediate_cert = | 1718 if (data.root_cert_filename) { |
1715 ImportCertFromFile(certs_dir, data.intermediate_cert_filename); | 1719 root_cert = ImportCertFromFile(certs_dir, data.root_cert_filename); |
1716 ASSERT_TRUE(intermediate_cert); | 1720 ASSERT_TRUE(root_cert); |
| 1721 intermediates.push_back(root_cert->os_cert_handle()); |
| 1722 } |
| 1723 |
1717 scoped_refptr<X509Certificate> ee_cert = | 1724 scoped_refptr<X509Certificate> ee_cert = |
1718 ImportCertFromFile(certs_dir, data.ee_cert_filename); | 1725 ImportCertFromFile(certs_dir, data.ee_cert_filename); |
1719 ASSERT_TRUE(ee_cert); | 1726 ASSERT_TRUE(ee_cert); |
1720 | 1727 |
1721 X509Certificate::OSCertHandles intermediates; | |
1722 intermediates.push_back(intermediate_cert->os_cert_handle()); | |
1723 | |
1724 scoped_refptr<X509Certificate> ee_chain = | 1728 scoped_refptr<X509Certificate> ee_chain = |
1725 X509Certificate::CreateFromHandle(ee_cert->os_cert_handle(), | 1729 X509Certificate::CreateFromHandle(ee_cert->os_cert_handle(), |
1726 intermediates); | 1730 intermediates); |
1727 ASSERT_TRUE(ee_chain); | 1731 ASSERT_TRUE(ee_chain); |
1728 | 1732 |
1729 int flags = 0; | 1733 int flags = 0; |
1730 CertVerifyResult verify_result; | 1734 CertVerifyResult verify_result; |
1731 Verify(ee_chain.get(), "127.0.0.1", flags, NULL, empty_cert_list_, | 1735 |
1732 &verify_result); | 1736 // Use a mock CertVerifyProc that returns success with a verified_cert of |
| 1737 // |ee_chain|. |
| 1738 // |
| 1739 // This is sufficient for the purposes of this test, as the checking for weak |
| 1740 // hashing algorithms is done by CertVerifyProc::Verify(). |
| 1741 scoped_refptr<CertVerifyProc> proc = |
| 1742 new MockCertVerifyProc(CertVerifyResult()); |
| 1743 proc->Verify(ee_chain.get(), "127.0.0.1", std::string(), flags, nullptr, |
| 1744 empty_cert_list_, &verify_result); |
1733 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD2), verify_result.has_md2); | 1745 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD2), verify_result.has_md2); |
1734 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD4), verify_result.has_md4); | 1746 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD4), verify_result.has_md4); |
1735 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD5), verify_result.has_md5); | 1747 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_MD5), verify_result.has_md5); |
1736 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_SHA1), verify_result.has_sha1); | 1748 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_SHA1), verify_result.has_sha1); |
1737 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_SHA1_LEAF), | 1749 EXPECT_EQ(!!(data.expected_algorithms & EXPECT_SHA1_LEAF), |
1738 verify_result.has_sha1_leaf); | 1750 verify_result.has_sha1_leaf); |
1739 } | 1751 } |
1740 | 1752 |
1741 // Unlike TEST/TEST_F, which are macros that expand to further macros, | |
1742 // INSTANTIATE_TEST_CASE_P is a macro that expands directly to code that | |
1743 // stringizes the arguments. As a result, macros passed as parameters (such as | |
1744 // prefix or test_case_name) will not be expanded by the preprocessor. To work | |
1745 // around this, indirect the macro for INSTANTIATE_TEST_CASE_P, so that the | |
1746 // pre-processor will expand macros such as MAYBE_test_name before | |
1747 // instantiating the test. | |
1748 #define WRAPPED_INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ | |
1749 INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) | |
1750 | |
1751 // The signature algorithm of the root CA should not matter. | 1753 // The signature algorithm of the root CA should not matter. |
1752 const WeakDigestTestData kVerifyRootCATestData[] = { | 1754 const WeakDigestTestData kVerifyRootCATestData[] = { |
1753 {"weak_digest_md5_root.pem", "weak_digest_sha1_intermediate.pem", | 1755 {"weak_digest_md5_root.pem", "weak_digest_sha1_intermediate.pem", |
1754 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1756 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1755 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | |
1756 // MD4 is not supported by OS X / NSS | |
1757 {"weak_digest_md4_root.pem", "weak_digest_sha1_intermediate.pem", | 1757 {"weak_digest_md4_root.pem", "weak_digest_sha1_intermediate.pem", |
1758 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1758 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1759 #endif | |
1760 {"weak_digest_md2_root.pem", "weak_digest_sha1_intermediate.pem", | 1759 {"weak_digest_md2_root.pem", "weak_digest_sha1_intermediate.pem", |
1761 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1760 "weak_digest_sha1_ee.pem", EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1762 }; | 1761 }; |
1763 INSTANTIATE_TEST_CASE_P(VerifyRoot, | 1762 INSTANTIATE_TEST_CASE_P(VerifyRoot, |
1764 CertVerifyProcWeakDigestTest, | 1763 CertVerifyProcWeakDigestTest, |
1765 testing::ValuesIn(kVerifyRootCATestData)); | 1764 testing::ValuesIn(kVerifyRootCATestData)); |
1766 | 1765 |
1767 // The signature algorithm of intermediates should be properly detected. | 1766 // The signature algorithm of intermediates should be properly detected. |
1768 const WeakDigestTestData kVerifyIntermediateCATestData[] = { | 1767 const WeakDigestTestData kVerifyIntermediateCATestData[] = { |
1769 {"weak_digest_sha1_root.pem", "weak_digest_md5_intermediate.pem", | 1768 {"weak_digest_sha1_root.pem", "weak_digest_md5_intermediate.pem", |
1770 "weak_digest_sha1_ee.pem", EXPECT_MD5 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1769 "weak_digest_sha1_ee.pem", EXPECT_MD5 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1771 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | |
1772 // MD4 is not supported by OS X / NSS | |
1773 {"weak_digest_sha1_root.pem", "weak_digest_md4_intermediate.pem", | 1770 {"weak_digest_sha1_root.pem", "weak_digest_md4_intermediate.pem", |
1774 "weak_digest_sha1_ee.pem", EXPECT_MD4 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1771 "weak_digest_sha1_ee.pem", EXPECT_MD4 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1775 #endif | |
1776 {"weak_digest_sha1_root.pem", "weak_digest_md2_intermediate.pem", | 1772 {"weak_digest_sha1_root.pem", "weak_digest_md2_intermediate.pem", |
1777 "weak_digest_sha1_ee.pem", EXPECT_MD2 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1773 "weak_digest_sha1_ee.pem", EXPECT_MD2 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1778 }; | 1774 }; |
1779 // Disabled on NSS - MD4 is not supported, and MD2 and MD5 are disabled. | 1775 |
1780 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 1776 INSTANTIATE_TEST_CASE_P(VerifyIntermediate, |
1781 #define MAYBE_VerifyIntermediate DISABLED_VerifyIntermediate | 1777 CertVerifyProcWeakDigestTest, |
1782 #else | 1778 testing::ValuesIn(kVerifyIntermediateCATestData)); |
1783 #define MAYBE_VerifyIntermediate VerifyIntermediate | |
1784 #endif | |
1785 WRAPPED_INSTANTIATE_TEST_CASE_P( | |
1786 MAYBE_VerifyIntermediate, | |
1787 CertVerifyProcWeakDigestTest, | |
1788 testing::ValuesIn(kVerifyIntermediateCATestData)); | |
1789 | 1779 |
1790 // The signature algorithm of end-entity should be properly detected. | 1780 // The signature algorithm of end-entity should be properly detected. |
1791 const WeakDigestTestData kVerifyEndEntityTestData[] = { | 1781 const WeakDigestTestData kVerifyEndEntityTestData[] = { |
1792 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", | 1782 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", |
1793 "weak_digest_md5_ee.pem", EXPECT_MD5 | EXPECT_SHA1 }, | 1783 "weak_digest_md5_ee.pem", EXPECT_MD5 | EXPECT_SHA1 }, |
1794 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | |
1795 // MD4 is not supported by OS X / NSS | |
1796 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", | 1784 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", |
1797 "weak_digest_md4_ee.pem", EXPECT_MD4 | EXPECT_SHA1 }, | 1785 "weak_digest_md4_ee.pem", EXPECT_MD4 | EXPECT_SHA1 }, |
1798 #endif | |
1799 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", | 1786 { "weak_digest_sha1_root.pem", "weak_digest_sha1_intermediate.pem", |
1800 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_SHA1 }, | 1787 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_SHA1 }, |
1801 }; | 1788 }; |
1802 // Disabled on NSS - NSS caches chains/signatures in such a way that cannot | |
1803 // be cleared until NSS is cleanly shutdown, which is not presently supported | |
1804 // in Chromium. | |
1805 // OSX 10.12+ stops building the chain at the first weak digest. | |
1806 #if defined(USE_NSS_CERTS) || defined(OS_IOS) || defined(OS_MACOSX) | |
1807 #define MAYBE_VerifyEndEntity DISABLED_VerifyEndEntity | |
1808 #else | |
1809 #define MAYBE_VerifyEndEntity VerifyEndEntity | |
1810 #endif | |
1811 WRAPPED_INSTANTIATE_TEST_CASE_P(MAYBE_VerifyEndEntity, | |
1812 CertVerifyProcWeakDigestTest, | |
1813 testing::ValuesIn(kVerifyEndEntityTestData)); | |
1814 | 1789 |
1815 // Incomplete chains should still report the status of the intermediate. | 1790 INSTANTIATE_TEST_CASE_P(VerifyEndEntity, |
| 1791 CertVerifyProcWeakDigestTest, |
| 1792 testing::ValuesIn(kVerifyEndEntityTestData)); |
| 1793 |
| 1794 // Incomplete chains do not report the status of the intermediate. |
| 1795 // Note: really each of these tests should also expect the digest algorithm of |
| 1796 // the intermediate (included as a comment). However CertVerifyProc::Verify() is |
| 1797 // unable to distinguish that this is an intermediate and not a trust anchor, so |
| 1798 // this intermediate is treated like a trust anchor. |
1816 const WeakDigestTestData kVerifyIncompleteIntermediateTestData[] = { | 1799 const WeakDigestTestData kVerifyIncompleteIntermediateTestData[] = { |
1817 {NULL, "weak_digest_md5_intermediate.pem", "weak_digest_sha1_ee.pem", | 1800 {NULL, "weak_digest_md5_intermediate.pem", "weak_digest_sha1_ee.pem", |
1818 EXPECT_MD5 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1801 /*EXPECT_MD5 |*/ EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1819 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | |
1820 // MD4 is not supported by OS X / NSS | |
1821 {NULL, "weak_digest_md4_intermediate.pem", "weak_digest_sha1_ee.pem", | 1802 {NULL, "weak_digest_md4_intermediate.pem", "weak_digest_sha1_ee.pem", |
1822 EXPECT_MD4 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1803 /*EXPECT_MD4 |*/ EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1823 #endif | |
1824 {NULL, "weak_digest_md2_intermediate.pem", "weak_digest_sha1_ee.pem", | 1804 {NULL, "weak_digest_md2_intermediate.pem", "weak_digest_sha1_ee.pem", |
1825 EXPECT_MD2 | EXPECT_SHA1 | EXPECT_SHA1_LEAF}, | 1805 /*EXPECT_MD2 |*/ EXPECT_SHA1 | EXPECT_SHA1_LEAF}, |
1826 }; | 1806 }; |
1827 // Disabled on NSS - libpkix does not return constructed chains on error, | 1807 |
1828 // preventing us from detecting/inspecting the verified chain. | 1808 INSTANTIATE_TEST_CASE_P( |
1829 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | |
1830 #define MAYBE_VerifyIncompleteIntermediate \ | |
1831 DISABLED_VerifyIncompleteIntermediate | |
1832 #else | |
1833 #define MAYBE_VerifyIncompleteIntermediate VerifyIncompleteIntermediate | |
1834 #endif | |
1835 WRAPPED_INSTANTIATE_TEST_CASE_P( | |
1836 MAYBE_VerifyIncompleteIntermediate, | 1809 MAYBE_VerifyIncompleteIntermediate, |
1837 CertVerifyProcWeakDigestTest, | 1810 CertVerifyProcWeakDigestTest, |
1838 testing::ValuesIn(kVerifyIncompleteIntermediateTestData)); | 1811 testing::ValuesIn(kVerifyIncompleteIntermediateTestData)); |
1839 | 1812 |
1840 // Incomplete chains should still report the status of the end-entity. | 1813 // Incomplete chains should report the status of the end-entity. |
| 1814 // Note: really each of these tests should also expect EXPECT_SHA1 (included as |
| 1815 // a comment). However CertVerifyProc::Verify() is unable to distinguish that |
| 1816 // this is an intermediate and not a trust anchor, so this intermediate is |
| 1817 // treated like a trust anchor. |
1841 const WeakDigestTestData kVerifyIncompleteEETestData[] = { | 1818 const WeakDigestTestData kVerifyIncompleteEETestData[] = { |
1842 { NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md5_ee.pem", | 1819 {NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md5_ee.pem", |
1843 EXPECT_MD5 | EXPECT_SHA1 }, | 1820 /*EXPECT_SHA1 |*/ EXPECT_MD5}, |
1844 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | 1821 {NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md4_ee.pem", |
1845 // MD4 is not supported by OS X / NSS | 1822 /*EXPECT_SHA1 |*/ EXPECT_MD4}, |
1846 { NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md4_ee.pem", | 1823 {NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md2_ee.pem", |
1847 EXPECT_MD4 | EXPECT_SHA1 }, | 1824 /*EXPECT_SHA1 |*/ EXPECT_MD2}, |
1848 #endif | |
1849 { NULL, "weak_digest_sha1_intermediate.pem", "weak_digest_md2_ee.pem", | |
1850 EXPECT_MD2 | EXPECT_SHA1 }, | |
1851 }; | 1825 }; |
1852 // Disabled on NSS - libpkix does not return constructed chains on error, | 1826 |
1853 // preventing us from detecting/inspecting the verified chain. | 1827 INSTANTIATE_TEST_CASE_P(VerifyIncompleteEndEntity, |
1854 // OSX 10.12+ stops building the chain at the first weak digest. | 1828 CertVerifyProcWeakDigestTest, |
1855 #if defined(USE_NSS_CERTS) || defined(OS_IOS) || defined(OS_MACOSX) | 1829 testing::ValuesIn(kVerifyIncompleteEETestData)); |
1856 #define MAYBE_VerifyIncompleteEndEntity DISABLED_VerifyIncompleteEndEntity | |
1857 #else | |
1858 #define MAYBE_VerifyIncompleteEndEntity VerifyIncompleteEndEntity | |
1859 #endif | |
1860 WRAPPED_INSTANTIATE_TEST_CASE_P( | |
1861 MAYBE_VerifyIncompleteEndEntity, | |
1862 CertVerifyProcWeakDigestTest, | |
1863 testing::ValuesIn(kVerifyIncompleteEETestData)); | |
1864 | 1830 |
1865 // Differing algorithms between the intermediate and the EE should still be | 1831 // Differing algorithms between the intermediate and the EE should still be |
1866 // reported. | 1832 // reported. |
1867 const WeakDigestTestData kVerifyMixedTestData[] = { | 1833 const WeakDigestTestData kVerifyMixedTestData[] = { |
1868 { "weak_digest_sha1_root.pem", "weak_digest_md5_intermediate.pem", | 1834 { "weak_digest_sha1_root.pem", "weak_digest_md5_intermediate.pem", |
1869 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_MD5 }, | 1835 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_MD5 }, |
1870 { "weak_digest_sha1_root.pem", "weak_digest_md2_intermediate.pem", | 1836 { "weak_digest_sha1_root.pem", "weak_digest_md2_intermediate.pem", |
1871 "weak_digest_md5_ee.pem", EXPECT_MD2 | EXPECT_MD5 }, | 1837 "weak_digest_md5_ee.pem", EXPECT_MD2 | EXPECT_MD5 }, |
1872 #if defined(USE_OPENSSL_CERTS) || defined(OS_WIN) | |
1873 // MD4 is not supported by OS X / NSS | |
1874 { "weak_digest_sha1_root.pem", "weak_digest_md4_intermediate.pem", | 1838 { "weak_digest_sha1_root.pem", "weak_digest_md4_intermediate.pem", |
1875 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_MD4 }, | 1839 "weak_digest_md2_ee.pem", EXPECT_MD2 | EXPECT_MD4 }, |
1876 #endif | |
1877 }; | 1840 }; |
1878 // NSS does not support MD4 and does not enable MD2 by default, making all | 1841 |
1879 // permutations invalid. | 1842 INSTANTIATE_TEST_CASE_P(VerifyMixed, |
1880 // OSX 10.12+ stops building the chain at the first weak digest. | 1843 CertVerifyProcWeakDigestTest, |
1881 #if defined(USE_NSS_CERTS) || defined(OS_IOS) || defined(OS_MACOSX) | 1844 testing::ValuesIn(kVerifyMixedTestData)); |
1882 #define MAYBE_VerifyMixed DISABLED_VerifyMixed | 1845 |
1883 #else | 1846 // The EE is a trusted certificate. Even though it uses weak hashes, these |
1884 #define MAYBE_VerifyMixed VerifyMixed | 1847 // should not be reported. |
1885 #endif | 1848 const WeakDigestTestData kVerifyTrustedEETestData[] = { |
1886 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1849 {NULL, NULL, "weak_digest_md5_ee.pem", 0}, |
1887 MAYBE_VerifyMixed, | 1850 {NULL, NULL, "weak_digest_md4_ee.pem", 0}, |
1888 CertVerifyProcWeakDigestTest, | 1851 {NULL, NULL, "weak_digest_md2_ee.pem", 0}, |
1889 testing::ValuesIn(kVerifyMixedTestData)); | 1852 {NULL, NULL, "weak_digest_sha1_ee.pem", 0}, |
| 1853 }; |
| 1854 |
| 1855 INSTANTIATE_TEST_CASE_P(VerifyTrustedEE, |
| 1856 CertVerifyProcWeakDigestTest, |
| 1857 testing::ValuesIn(kVerifyTrustedEETestData)); |
1890 | 1858 |
1891 // For the list of valid hostnames, see | 1859 // For the list of valid hostnames, see |
1892 // net/cert/data/ssl/certificates/subjectAltName_sanity_check.pem | 1860 // net/cert/data/ssl/certificates/subjectAltName_sanity_check.pem |
1893 static const struct CertVerifyProcNameData { | 1861 static const struct CertVerifyProcNameData { |
1894 const char* hostname; | 1862 const char* hostname; |
1895 bool valid; // Whether or not |hostname| matches a subjectAltName. | 1863 bool valid; // Whether or not |hostname| matches a subjectAltName. |
1896 } kVerifyNameData[] = { | 1864 } kVerifyNameData[] = { |
1897 { "127.0.0.1", false }, // Don't match the common name | 1865 { "127.0.0.1", false }, // Don't match the common name |
1898 { "127.0.0.2", true }, // Matches the iPAddress SAN (IPv4) | 1866 { "127.0.0.2", true }, // Matches the iPAddress SAN (IPv4) |
1899 { "FE80:0:0:0:0:0:0:1", true }, // Matches the iPAddress SAN (IPv6) | 1867 { "FE80:0:0:0:0:0:0:1", true }, // Matches the iPAddress SAN (IPv6) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 &verify_result); | 1909 &verify_result); |
1942 if (data.valid) { | 1910 if (data.valid) { |
1943 EXPECT_THAT(error, IsOk()); | 1911 EXPECT_THAT(error, IsOk()); |
1944 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID); | 1912 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID); |
1945 } else { | 1913 } else { |
1946 EXPECT_THAT(error, IsError(ERR_CERT_COMMON_NAME_INVALID)); | 1914 EXPECT_THAT(error, IsError(ERR_CERT_COMMON_NAME_INVALID)); |
1947 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID); | 1915 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID); |
1948 } | 1916 } |
1949 } | 1917 } |
1950 | 1918 |
1951 WRAPPED_INSTANTIATE_TEST_CASE_P( | 1919 INSTANTIATE_TEST_CASE_P(VerifyName, |
1952 VerifyName, | 1920 CertVerifyProcNameTest, |
1953 CertVerifyProcNameTest, | 1921 testing::ValuesIn(kVerifyNameData)); |
1954 testing::ValuesIn(kVerifyNameData)); | |
1955 | 1922 |
1956 #if defined(OS_MACOSX) && !defined(OS_IOS) | 1923 #if defined(OS_MACOSX) && !defined(OS_IOS) |
1957 // Test that CertVerifyProcMac reacts appropriately when Apple's certificate | 1924 // Test that CertVerifyProcMac reacts appropriately when Apple's certificate |
1958 // verifier rejects a certificate with a fatal error. This is a regression | 1925 // verifier rejects a certificate with a fatal error. This is a regression |
1959 // test for https://crbug.com/472291. | 1926 // test for https://crbug.com/472291. |
1960 // (Since 10.12, this causes a recoverable error instead of a fatal one.) | 1927 // (Since 10.12, this causes a recoverable error instead of a fatal one.) |
1961 // TODO(mattm): Try to find a different way to cause a fatal error that works | 1928 // TODO(mattm): Try to find a different way to cause a fatal error that works |
1962 // on 10.12. | 1929 // on 10.12. |
1963 TEST_F(CertVerifyProcTest, LargeKey) { | 1930 TEST_F(CertVerifyProcTest, LargeKey) { |
1964 // Load root_ca_cert.pem into the test root store. | 1931 // Load root_ca_cert.pem into the test root store. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 int flags = 0; | 2042 int flags = 0; |
2076 CertVerifyResult verify_result; | 2043 CertVerifyResult verify_result; |
2077 int error = Verify(cert.get(), "127.0.0.1", flags, NULL, empty_cert_list_, | 2044 int error = Verify(cert.get(), "127.0.0.1", flags, NULL, empty_cert_list_, |
2078 &verify_result); | 2045 &verify_result); |
2079 EXPECT_EQ(OK, error); | 2046 EXPECT_EQ(OK, error); |
2080 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); | 2047 histograms.ExpectTotalCount(kTLSFeatureExtensionHistogram, 0); |
2081 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); | 2048 histograms.ExpectTotalCount(kTLSFeatureExtensionOCSPHistogram, 0); |
2082 } | 2049 } |
2083 | 2050 |
2084 } // namespace net | 2051 } // namespace net |
OLD | NEW |