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

Unified Diff: net/cert/x509_certificate_unittest.cc

Issue 2761333002: Add a DevTools warning for a missing subjectAltName (Closed)
Patch Set: Feedback & fixes Created 3 years, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/x509_certificate_unittest.cc
diff --git a/net/cert/x509_certificate_unittest.cc b/net/cert/x509_certificate_unittest.cc
index d2974e56d679db598ec43145274374b5f2359164..62a2c2f150d8ddae49e9e2187debfb0bea7f6922 100644
--- a/net/cert/x509_certificate_unittest.cc
+++ b/net/cert/x509_certificate_unittest.cc
@@ -397,9 +397,16 @@ TEST(X509CertificateTest, ParseSubjectAltNames) {
ImportCertFromFile(certs_dir, "subjectAltName_sanity_check.pem");
ASSERT_NE(static_cast<X509Certificate*>(NULL), san_cert.get());
+ // Ensure that testing for SAN without using it is accepted.
+ EXPECT_TRUE(san_cert->GetSubjectAltName(nullptr, nullptr));
+
+ // Ensure that it's possible to get just dNSNames.
std::vector<std::string> dns_names;
+ EXPECT_TRUE(san_cert->GetSubjectAltName(&dns_names, nullptr));
+
+ // Ensure that it's possible to get just iPAddresses.
std::vector<std::string> ip_addresses;
- san_cert->GetSubjectAltName(&dns_names, &ip_addresses);
+ EXPECT_TRUE(san_cert->GetSubjectAltName(nullptr, &ip_addresses));
// Ensure that DNS names are correctly parsed.
ASSERT_EQ(1U, dns_names.size());
@@ -426,6 +433,16 @@ TEST(X509CertificateTest, ParseSubjectAltNames) {
// Ensure the subjectAltName dirName has not influenced the handling of
// the subject commonName.
EXPECT_EQ("127.0.0.1", san_cert->subject().common_name);
+
+ scoped_refptr<X509Certificate> no_san_cert =
+ ImportCertFromFile(certs_dir, "salesforce_com_test.pem");
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), no_san_cert.get());
+
+ EXPECT_NE(0u, dns_names.size());
+ EXPECT_NE(0u, ip_addresses.size());
+ EXPECT_FALSE(no_san_cert->GetSubjectAltName(&dns_names, &ip_addresses));
+ EXPECT_EQ(0u, dns_names.size());
+ EXPECT_EQ(0u, ip_addresses.size());
}
#if defined(USE_NSS_CERTS)
« 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