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

Unified Diff: net/base/x509_certificate_unittest.cc

Issue 9950065: Properly parse IPv6 subjectAltNames when USE_OPENSSL is set (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pedantry Created 8 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/base/x509_certificate_openssl.cc ('k') | net/data/ssl/certificates/README » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_certificate_unittest.cc
diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc
index 4855d89bf41060f3f676838ff5d2b9e8b1cdd2dd..d33b1d895c5b06ccf6b8829177ed1f8b926f5844 100644
--- a/net/base/x509_certificate_unittest.cc
+++ b/net/base/x509_certificate_unittest.cc
@@ -438,6 +438,44 @@ TEST(X509CertificateTest, CAFingerprints) {
cert_chain3_ca_fingerprint, 20) == 0);
}
+TEST(X509CertificateTest, ParseSubjectAltNames) {
+ FilePath certs_dir = GetTestCertsDirectory();
+
+ scoped_refptr<X509Certificate> san_cert =
+ ImportCertFromFile(certs_dir, "subjectAltName_sanity_check.pem");
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), san_cert);
+
+ std::vector<std::string> dns_names;
+ std::vector<std::string> ip_addresses;
+ san_cert->GetSubjectAltName(&dns_names, &ip_addresses);
+
+ // Ensure that DNS names are correctly parsed.
+ ASSERT_EQ(1U, dns_names.size());
+ EXPECT_EQ("test.example", dns_names[0]);
+
+ // Ensure that both IPv4 and IPv6 addresses are correctly parsed.
+ ASSERT_EQ(2U, ip_addresses.size());
+
+ static const unsigned char kIPv4Address[] = {
agl 2012/04/03 10:41:22 s/unsigned char/uint8 ?
Ryan Sleevi 2012/04/03 17:17:18 Done. Since this file was a mixed of unsigned char
+ 0x7F, 0x00, 0x00, 0x02
+ };
+ ASSERT_EQ(arraysize(kIPv4Address), ip_addresses[0].size());
+ EXPECT_EQ(0, memcmp(ip_addresses[0].data(), kIPv4Address,
+ arraysize(kIPv4Address)));
+
+ static const unsigned char kIPv6Address[] = {
agl 2012/04/03 10:41:22 ditto
+ 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
+ };
+ ASSERT_EQ(arraysize(kIPv6Address), ip_addresses[1].size());
+ EXPECT_EQ(0, memcmp(ip_addresses[1].data(), kIPv6Address,
+ arraysize(kIPv6Address)));
+
+ // Ensure the subjectAltName dirName has not influenced the handling of
+ // the subject commonName.
+ EXPECT_EQ("127.0.0.1", san_cert->subject().common_name);
+}
+
TEST(X509CertificateTest, ExtractSPKIFromDERCert) {
FilePath certs_dir = GetTestCertsDirectory();
scoped_refptr<X509Certificate> cert =
« no previous file with comments | « net/base/x509_certificate_openssl.cc ('k') | net/data/ssl/certificates/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698