Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: net/cert/cert_verify_proc_unittest.cc

Issue 949633002: Include both certificate chains in invalid cert reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a comment to cert logger pb Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 error = 847 error =
848 Verify(cert.get(), "intranet", 0, NULL, empty_cert_list_, &verify_result); 848 Verify(cert.get(), "intranet", 0, NULL, empty_cert_list_, &verify_result);
849 EXPECT_EQ(OK, error); 849 EXPECT_EQ(OK, error);
850 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_NON_UNIQUE_NAME); 850 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_NON_UNIQUE_NAME);
851 } 851 }
852 852
853 // Test that the certificate returned in CertVerifyResult is able to reorder 853 // Test that the certificate returned in CertVerifyResult is able to reorder
854 // certificates that are not ordered from end-entity to root. While this is 854 // certificates that are not ordered from end-entity to root. While this is
855 // a protocol violation if sent during a TLS handshake, if multiple sources 855 // a protocol violation if sent during a TLS handshake, if multiple sources
856 // of intermediate certificates are combined, it's possible that order may 856 // of intermediate certificates are combined, it's possible that order may
857 // not be maintained. 857 // not be maintained. Also test that the chain as received by the client is
858 // present in the |unverified_server_cert| field of CertVerifyResult.
858 TEST_F(CertVerifyProcTest, VerifyReturnChainProperlyOrdered) { 859 TEST_F(CertVerifyProcTest, VerifyReturnChainProperlyOrdered) {
859 if (!SupportsReturningVerifiedChain()) { 860 if (!SupportsReturningVerifiedChain()) {
860 LOG(INFO) << "Skipping this test in this platform."; 861 LOG(INFO) << "Skipping this test in this platform.";
861 return; 862 return;
862 } 863 }
863 864
864 base::FilePath certs_dir = GetTestCertsDirectory(); 865 base::FilePath certs_dir = GetTestCertsDirectory();
865 CertificateList certs = CreateCertificateListFromFile( 866 CertificateList certs = CreateCertificateListFromFile(
866 certs_dir, "x509_verify_results.chain.pem", 867 certs_dir, "x509_verify_results.chain.pem",
867 X509Certificate::FORMAT_AUTO); 868 X509Certificate::FORMAT_AUTO);
(...skipping 29 matching lines...) Expand all
897 EXPECT_TRUE(X509Certificate::IsSameOSCert( 898 EXPECT_TRUE(X509Certificate::IsSameOSCert(
898 google_full_chain->os_cert_handle(), 899 google_full_chain->os_cert_handle(),
899 verify_result.verified_cert->os_cert_handle())); 900 verify_result.verified_cert->os_cert_handle()));
900 const X509Certificate::OSCertHandles& return_intermediates = 901 const X509Certificate::OSCertHandles& return_intermediates =
901 verify_result.verified_cert->GetIntermediateCertificates(); 902 verify_result.verified_cert->GetIntermediateCertificates();
902 ASSERT_EQ(2U, return_intermediates.size()); 903 ASSERT_EQ(2U, return_intermediates.size());
903 EXPECT_TRUE(X509Certificate::IsSameOSCert(return_intermediates[0], 904 EXPECT_TRUE(X509Certificate::IsSameOSCert(return_intermediates[0],
904 certs[1]->os_cert_handle())); 905 certs[1]->os_cert_handle()));
905 EXPECT_TRUE(X509Certificate::IsSameOSCert(return_intermediates[1], 906 EXPECT_TRUE(X509Certificate::IsSameOSCert(return_intermediates[1],
906 certs[2]->os_cert_handle())); 907 certs[2]->os_cert_handle()));
908
909 // The |unverified_server_cert| field should contain the chain exactly
910 // as sent by the server.
911 EXPECT_EQ(google_full_chain, verify_result.unverified_server_cert);
912 EXPECT_TRUE(X509Certificate::IsSameOSCert(
913 google_full_chain->os_cert_handle(),
914 verify_result.unverified_server_cert->os_cert_handle()));
915 const X509Certificate::OSCertHandles& unverified_server_intermediates =
916 verify_result.unverified_server_cert->GetIntermediateCertificates();
917 ASSERT_EQ(2U, unverified_server_intermediates.size());
918 EXPECT_TRUE(X509Certificate::IsSameOSCert(unverified_server_intermediates[0],
919 certs[2]->os_cert_handle()));
920 EXPECT_TRUE(X509Certificate::IsSameOSCert(unverified_server_intermediates[1],
921 certs[1]->os_cert_handle()));
907 } 922 }
908 923
909 // Test that Verify() filters out certificates which are not related to 924 // Test that Verify() filters out certificates which are not related to
910 // or part of the certificate chain being verified. 925 // or part of the certificate chain being verified.
911 TEST_F(CertVerifyProcTest, VerifyReturnChainFiltersUnrelatedCerts) { 926 TEST_F(CertVerifyProcTest, VerifyReturnChainFiltersUnrelatedCerts) {
912 if (!SupportsReturningVerifiedChain()) { 927 if (!SupportsReturningVerifiedChain()) {
913 LOG(INFO) << "Skipping this test in this platform."; 928 LOG(INFO) << "Skipping this test in this platform.";
914 return; 929 return;
915 } 930 }
916 931
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID); 1602 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_COMMON_NAME_INVALID);
1588 } 1603 }
1589 } 1604 }
1590 1605
1591 WRAPPED_INSTANTIATE_TEST_CASE_P( 1606 WRAPPED_INSTANTIATE_TEST_CASE_P(
1592 VerifyName, 1607 VerifyName,
1593 CertVerifyProcNameTest, 1608 CertVerifyProcNameTest,
1594 testing::ValuesIn(kVerifyNameData)); 1609 testing::ValuesIn(kVerifyNameData));
1595 1610
1596 } // namespace net 1611 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698