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

Unified Diff: net/base/x509_certificate_unittest.cc

Issue 8608003: Parse individual X.509 name components on Windows, rather than their stringified form (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Anonymized certs Created 9 years, 1 month 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_cert_types_mac.cc ('k') | net/base/x509_certificate_win.cc » ('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 f48336226c0c9701989bb2df21e6a299f23acd56..686f20fe9b3c722600f6747fb311f8d1602ab3ee 100644
--- a/net/base/x509_certificate_unittest.cc
+++ b/net/base/x509_certificate_unittest.cc
@@ -375,6 +375,56 @@ TEST(X509CertificateTest, ThawteCertParsing) {
#endif
}
+// Test that all desired AttributeAndValue pairs can be extracted when only
+// a single RelativeDistinguishedName is present. "Normally" there is only
+// one AVA per RDN, but some CAs place all AVAs within a single RDN.
+// This is a regression test for http://crbug.com/101009
+TEST(X509CertificateTest, MultivalueRDN) {
+ FilePath certs_dir = GetTestCertsDirectory();
+
+ scoped_refptr<X509Certificate> multivalue_rdn_cert =
+ ImportCertFromFile(certs_dir, "multivalue_rdn.pem");
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), multivalue_rdn_cert);
+
+ const CertPrincipal& subject = multivalue_rdn_cert->subject();
+ EXPECT_EQ("Multivalue RDN Test", subject.common_name);
+ EXPECT_EQ("", subject.locality_name);
+ EXPECT_EQ("", subject.state_or_province_name);
+ EXPECT_EQ("US", subject.country_name);
+ EXPECT_EQ(0U, subject.street_addresses.size());
+ ASSERT_EQ(1U, subject.organization_names.size());
+ EXPECT_EQ("Chromium", subject.organization_names[0]);
+ ASSERT_EQ(1U, subject.organization_unit_names.size());
+ EXPECT_EQ("Chromium net_unittests", subject.organization_unit_names[0]);
+ ASSERT_EQ(1U, subject.domain_components.size());
+ EXPECT_EQ("Chromium", subject.domain_components[0]);
+}
+
+// Test that characters which would normally be escaped in the string form,
+// such as '=' or '"', are not escaped when parsed as individual components.
+// This is a regression test for http://crbug.com/102839
+TEST(X509CertificateTest, UnescapedSpecialCharacters) {
+ FilePath certs_dir = GetTestCertsDirectory();
+
+ scoped_refptr<X509Certificate> unescaped_cert =
+ ImportCertFromFile(certs_dir, "unescaped.pem");
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), unescaped_cert);
+
+ const CertPrincipal& subject = unescaped_cert->subject();
+ EXPECT_EQ("127.0.0.1", subject.common_name);
+ EXPECT_EQ("Mountain View", subject.locality_name);
+ EXPECT_EQ("California", subject.state_or_province_name);
+ EXPECT_EQ("US", subject.country_name);
+ ASSERT_EQ(1U, subject.street_addresses.size());
+ EXPECT_EQ("1600 Amphitheatre Parkway", subject.street_addresses[0]);
+ ASSERT_EQ(1U, subject.organization_names.size());
+ EXPECT_EQ("Chromium = \"net_unittests\"", subject.organization_names[0]);
+ ASSERT_EQ(2U, subject.organization_unit_names.size());
+ EXPECT_EQ("net_unittests", subject.organization_unit_names[0]);
+ EXPECT_EQ("Chromium", subject.organization_unit_names[1]);
+ EXPECT_EQ(0U, subject.domain_components.size());
+}
+
TEST(X509CertificateTest, PaypalNullCertParsing) {
scoped_refptr<X509Certificate> paypal_null_cert(
X509Certificate::CreateFromBytes(
« no previous file with comments | « net/base/x509_cert_types_mac.cc ('k') | net/base/x509_certificate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698