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

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

Issue 1988993002: Check self-signed certificate names and signatures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dependency on openssl -text format Created 4 years, 6 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
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/x509_certificate.h" 5 #include "net/cert/x509_certificate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 741
742 scoped_refptr<X509Certificate> cert( 742 scoped_refptr<X509Certificate> cert(
743 ImportCertFromFile(certs_dir, "mit.davidben.der")); 743 ImportCertFromFile(certs_dir, "mit.davidben.der"));
744 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get()); 744 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get());
745 EXPECT_FALSE(X509Certificate::IsSelfSigned(cert->os_cert_handle())); 745 EXPECT_FALSE(X509Certificate::IsSelfSigned(cert->os_cert_handle()));
746 746
747 scoped_refptr<X509Certificate> self_signed( 747 scoped_refptr<X509Certificate> self_signed(
748 ImportCertFromFile(certs_dir, "aia-root.pem")); 748 ImportCertFromFile(certs_dir, "aia-root.pem"));
749 ASSERT_NE(static_cast<X509Certificate*>(NULL), self_signed.get()); 749 ASSERT_NE(static_cast<X509Certificate*>(NULL), self_signed.get());
750 EXPECT_TRUE(X509Certificate::IsSelfSigned(self_signed->os_cert_handle())); 750 EXPECT_TRUE(X509Certificate::IsSelfSigned(self_signed->os_cert_handle()));
751
752 scoped_refptr<X509Certificate> bad_name(
753 ImportCertFromFile(certs_dir, "self-signed-invalid-name.pem"));
754 ASSERT_NE(static_cast<X509Certificate*>(NULL), bad_name.get());
755 EXPECT_FALSE(X509Certificate::IsSelfSigned(bad_name->os_cert_handle()));
756
757 scoped_refptr<X509Certificate> bad_sig(
758 ImportCertFromFile(certs_dir, "self-signed-invalid-sig.pem"));
759 ASSERT_NE(static_cast<X509Certificate*>(NULL), bad_sig.get());
760 EXPECT_FALSE(X509Certificate::IsSelfSigned(bad_sig->os_cert_handle()));
751 } 761 }
752 762
753 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) { 763 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) {
754 static const unsigned char kPolicyRootDN[] = { 764 static const unsigned char kPolicyRootDN[] = {
755 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 765 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
756 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, 766 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74,
757 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41 767 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41
758 }; 768 };
759 static const unsigned char kPolicyIntermediateDN[] = { 769 static const unsigned char kPolicyIntermediateDN[] = {
760 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 770 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 &actual_type); 1229 &actual_type);
1220 1230
1221 EXPECT_EQ(data.expected_bits, actual_bits); 1231 EXPECT_EQ(data.expected_bits, actual_bits);
1222 EXPECT_EQ(data.expected_type, actual_type); 1232 EXPECT_EQ(data.expected_type, actual_type);
1223 } 1233 }
1224 1234
1225 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, 1235 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest,
1226 testing::ValuesIn(kPublicKeyInfoTestData)); 1236 testing::ValuesIn(kPublicKeyInfoTestData));
1227 1237
1228 } // namespace net 1238 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/cert/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698