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

Unified Diff: net/cert/x509_certificate_unittest.cc

Issue 1720653002: Add new functions to handle UPN and email addresses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ios build breakage Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/cert/x509_util_nss.h » ('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 362f7ff0991ab490e4a45d596f7a4b672af4f3bd..0c543078ea4e01711e7d9ce48219ec9c5f22679f 100644
--- a/net/cert/x509_certificate_unittest.cc
+++ b/net/cert/x509_certificate_unittest.cc
@@ -17,6 +17,7 @@
#include "net/base/net_errors.h"
#include "net/base/test_data_directory.h"
#include "net/cert/asn1_util.h"
+#include "net/cert/x509_util_nss.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_certificate_data.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -507,6 +508,29 @@ TEST(X509CertificateTest, ParseSubjectAltNames) {
EXPECT_EQ("127.0.0.1", san_cert->subject().common_name);
}
+#if defined(USE_NSS_CERTS)
+TEST(X509CertificateTest, ParseClientSubjectAltNames) {
+ base::FilePath certs_dir = GetTestCertsDirectory();
+
+ // This cert contains one rfc822Name field, and one Microsoft UPN
+ // otherName field.
+ scoped_refptr<X509Certificate> san_cert =
+ ImportCertFromFile(certs_dir, "client_3.pem");
+ ASSERT_NE(static_cast<X509Certificate*>(NULL), san_cert.get());
+
+ std::vector<std::string> rfc822_names;
+ net::x509_util::GetRFC822SubjectAltNames(san_cert->os_cert_handle(),
+ &rfc822_names);
+ ASSERT_EQ(1U, rfc822_names.size());
+ EXPECT_EQ("santest@example.com", rfc822_names[0]);
+
+ std::vector<std::string> upn_names;
+ net::x509_util::GetUPNSubjectAltNames(san_cert->os_cert_handle(), &upn_names);
+ ASSERT_EQ(1U, upn_names.size());
+ EXPECT_EQ("santest@ad.corp.example.com", upn_names[0]);
+}
+#endif // defined(USE_NSS_CERTS)
+
TEST(X509CertificateTest, ExtractSPKIFromDERCert) {
base::FilePath certs_dir = GetTestCertsDirectory();
scoped_refptr<X509Certificate> cert =
« no previous file with comments | « no previous file | net/cert/x509_util_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698