Skip to content

Commit

Permalink
Revert 69356 - Regenerate the root certificate and end-entity certifi…
Browse files Browse the repository at this point in the history
…cates used for various tests in net_unittests, now that Windows can temporarily trust certificates for the duration of tests.

In addition, add unittests for net::TestRootCerts, which depend on the certs being tested not being trusted by the system beforehand.

BUG=8470, 5552
TEST=TestRootCertsTest.*

Review URL: http://codereview.chromium.org/5535006

[email protected]

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69363 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
[email protected] committed Dec 16, 2010
1 parent c0b0a69 commit ec2f688
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 623 deletions.
16 changes: 8 additions & 8 deletions net/base/cert_database_nss_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ TEST_F(CertDatabaseNSSTest, ImportFromPKCS12AndExportAgain) {
}

TEST_F(CertDatabaseNSSTest, ImportCACert_SSLTrust) {
std::string cert_data = ReadTestFile("root_ca_cert.pem");
std::string cert_data = ReadTestFile("root_ca_cert.crt");

CertificateList certs =
X509Certificate::CreateCertificateListFromBytes(
Expand All @@ -187,7 +187,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACert_SSLTrust) {
CertificateList cert_list = ListCertsInSlot(slot_.get());
ASSERT_EQ(1U, cert_list.size());
scoped_refptr<X509Certificate> cert(cert_list[0]);
EXPECT_EQ("Test Root CA", cert->subject().common_name);
EXPECT_EQ("Test CA", cert->subject().common_name);

EXPECT_EQ(CertDatabase::TRUSTED_SSL,
cert_db_.GetCertTrust(cert.get(), CA_CERT));
Expand All @@ -201,7 +201,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACert_SSLTrust) {
}

TEST_F(CertDatabaseNSSTest, ImportCACert_EmailTrust) {
std::string cert_data = ReadTestFile("root_ca_cert.pem");
std::string cert_data = ReadTestFile("root_ca_cert.crt");

CertificateList certs =
X509Certificate::CreateCertificateListFromBytes(
Expand All @@ -219,7 +219,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACert_EmailTrust) {
CertificateList cert_list = ListCertsInSlot(slot_.get());
ASSERT_EQ(1U, cert_list.size());
scoped_refptr<X509Certificate> cert(cert_list[0]);
EXPECT_EQ("Test Root CA", cert->subject().common_name);
EXPECT_EQ("Test CA", cert->subject().common_name);

EXPECT_EQ(CertDatabase::TRUSTED_EMAIL,
cert_db_.GetCertTrust(cert.get(), CA_CERT));
Expand All @@ -232,7 +232,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACert_EmailTrust) {
}

TEST_F(CertDatabaseNSSTest, ImportCACert_ObjSignTrust) {
std::string cert_data = ReadTestFile("root_ca_cert.pem");
std::string cert_data = ReadTestFile("root_ca_cert.crt");

CertificateList certs =
X509Certificate::CreateCertificateListFromBytes(
Expand All @@ -250,7 +250,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACert_ObjSignTrust) {
CertificateList cert_list = ListCertsInSlot(slot_.get());
ASSERT_EQ(1U, cert_list.size());
scoped_refptr<X509Certificate> cert(cert_list[0]);
EXPECT_EQ("Test Root CA", cert->subject().common_name);
EXPECT_EQ("Test CA", cert->subject().common_name);

EXPECT_EQ(CertDatabase::TRUSTED_OBJ_SIGN,
cert_db_.GetCertTrust(cert.get(), CA_CERT));
Expand Down Expand Up @@ -391,7 +391,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACertHierarchyTree) {
}

TEST_F(CertDatabaseNSSTest, ImportCACertNotHierarchy) {
std::string cert_data = ReadTestFile("root_ca_cert.pem");
std::string cert_data = ReadTestFile("root_ca_cert.crt");
CertificateList certs =
X509Certificate::CreateCertificateListFromBytes(
cert_data.data(), cert_data.size(), X509Certificate::FORMAT_AUTO);
Expand All @@ -415,7 +415,7 @@ TEST_F(CertDatabaseNSSTest, ImportCACertNotHierarchy) {

CertificateList cert_list = ListCertsInSlot(slot_.get());
ASSERT_EQ(1U, cert_list.size());
EXPECT_EQ("Test Root CA", cert_list[0]->subject().common_name);
EXPECT_EQ("Test CA", cert_list[0]->subject().common_name);
}

TEST_F(CertDatabaseNSSTest, ImportServerCert) {
Expand Down
114 changes: 0 additions & 114 deletions net/base/test_root_certs_unittest.cc

This file was deleted.

48 changes: 7 additions & 41 deletions net/data/ssl/certificates/README
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,17 @@ unit tests.
- dod_root_ca_2_cert.der : A certificate chain for regression tests of
http://crbug.com/31497.

- expired_cert.pem : An expired certificate, used by test_server.cc.

- ok_cert.pem : A valid certificate, used by test_server.cc

- root_ca_cert.crt : The testing root CA used to sign the test_server.cc's
certificates.

- unosoft_hu_cert : Certificate used by X509CertificateTest.UnoSoftCertParsing.

- client.p12 : A PKCS #12 file containing a client certificate and a private
key created for testing. The password is "12345".

- punycodetest.der : A test self-signed server certificate with punycode name.
The common name is "xn--wgv71a119e.com" (日本語.com)

=====
Generated Test Certificates:
=====
The following certificates were generated locally, and are primarily used
by test_server.cc and test_server.py. Each file contains the certificate
and associated private key.
- expired_cert.pem : An expired certificate, used by test_server.cc.
- ok_cert.pem : A valid certificate, used by test_server.cc and others
- root_ca_cert.pem : The test root CA certificate, used to sign the test
certificates.

In addition, two support files are provided to make it easy to make
modifications or regenerate these certificates.
- openssl_ca.cnf : The configuration file used to generate the test CA
certificate and sign certificate requests.
- openssl_cert.cnf : The configuration file used to generate the certificate
requests for the ok and expired certificates.

The following commands were used to generated the test root certificates
Note: Be sure to adjust path slashes as appropriate for your platform.

mkdir root_ca
mkdir root_ca\private
mkdir root_ca\newcerts
echo 01 > root_ca\serial
[On Windows]
copy nul: root_ca\index.txt
copy nul: root_ca\index.txt.attr
[On POSIX]
touch root_ca\index.txt
touch root_ca\index.txt.attr

openssl req -new -x509 -days 18250 -keyout root_ca\private\cacert.key -out root_ca\cacert.pem -config openssl_ca.cnf
openssl req -new -keyout expired_cert.key -out expired_cert.req -config openssl_cert.cnf
openssl req -new -keyout ok_cert.key -out ok_cert.req -config openssl_cert.cnf
openssl ca -name CA_root -extensions user_cert -startdate 060101000000Z -enddate 070101000000Z -in expired_cert.req -out expired_cert.pem -config openssl_ca.cnf
openssl ca -name CA_root -extensions user_cert -days 18250 -in ok_cert.req -out ok_cert.pem -config openssl_ca.cnf

Each generated certificate (.pem) and private key (.key) were then combined
into a single file matching the naming scheme described above.
110 changes: 37 additions & 73 deletions net/data/ssl/certificates/expired_cert.pem
Original file line number Diff line number Diff line change
@@ -1,77 +1,41 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, ST=California, L=Mountain View, O=Test CA, CN=Test Root CA
Validity
Not Before: Jan 1 00:00:00 2006 GMT
Not After : Jan 1 00:00:00 2007 GMT
Subject: C=US, ST=California, L=Mountain View, O=Test CA, CN=127.0.0.1
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (1024 bit)
Modulus (1024 bit):
00:d3:b1:98:19:4f:40:2b:f0:73:a0:e1:9d:af:32:
36:cb:62:aa:d9:9e:81:a1:60:1a:a8:2f:1a:6f:f3:
0e:5e:31:50:a6:a3:f3:15:b1:71:8e:e7:e6:9b:ed:
7f:b5:ff:2f:3e:b3:50:83:5b:70:a6:70:80:32:d5:
26:6c:67:bb:40:41:0d:b7:63:f0:60:b8:63:d0:ad:
10:be:4b:ad:b2:57:9f:c1:fc:42:2e:56:46:71:b8:
78:00:28:9e:ec:80:2d:8d:a5:4e:c6:3c:e0:53:9a:
a3:c8:4b:3c:58:0f:89:4c:64:93:c0:db:49:a4:85:
1e:50:31:b6:4e:66:c7:a1:fb
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Key Identifier:
32:7B:D6:18:4F:26:9C:71:90:B5:37:FF:E4:33:5E:C8:C5:02:34:90
X509v3 Authority Key Identifier:
keyid:CB:0C:83:29:5E:38:A2:D6:9F:F7:76:FB:B3:B6:48:84:4E:F8:4D:F3

X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Subject Alternative Name:
IP Address:127.0.0.1
Signature Algorithm: sha1WithRSAEncryption
66:6b:d6:b8:e5:77:c8:e5:af:6d:5f:f9:97:cd:ae:72:f0:68:
23:28:b2:58:d2:6d:b0:37:5f:ec:36:d5:77:af:a2:80:02:27:
02:43:84:e7:de:54:7a:40:43:06:fd:93:78:59:16:d4:6f:e5:
a0:a5:6d:98:26:1b:6d:bf:67:92:67:e6:d1:d2:e7:e0:b2:5d:
ee:83:00:ab:1a:15:bd:25:a7:be:36:26:06:34:3b:1c:5d:be:
21:31:45:51:4c:0e:83:c2:04:e6:fd:2e:a9:94:f8:8a:4e:ff:
af:89:ac:47:4c:85:79:19:f0:68:32:4c:aa:c0:6a:6c:9f:dc:
4d:50
-----BEGIN CERTIFICATE-----
MIICujCCAiOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzET
MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
A1UECgwHVGVzdCBDQTEVMBMGA1UEAwwMVGVzdCBSb290IENBMB4XDTA2MDEwMTAw
MDAwMFoXDTA3MDEwMTAwMDAwMFowYDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNh
bGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB1Rlc3Qg
Q0ExEjAQBgNVBAMMCTEyNy4wLjAuMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
gYEA07GYGU9AK/BzoOGdrzI2y2Kq2Z6BoWAaqC8ab/MOXjFQpqPzFbFxjufmm+1/
tf8vPrNQg1twpnCAMtUmbGe7QEENt2PwYLhj0K0QvkutslefwfxCLlZGcbh4ACie
7IAtjaVOxjzgU5qjyEs8WA+JTGSTwNtJpIUeUDG2TmbHofsCAwEAAaOBgDB+MAwG
A1UdEwEB/wQCMAAwHQYDVR0OBBYEFDJ71hhPJpxxkLU3/+QzXsjFAjSQMB8GA1Ud
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eztyJV3n96lMDIc4lEzplysDw/TD6ZGQJABzYFsSBoUbyir8CUFoXnfXzxKXDr
80FI2m95nHP2AoLNznTHu1ZoHBS1kIPkZw/PM7o3Pndbl/R3OCk3sfJ1JQJABSB7
PkBCIZ4471GF9uyuB8CZ1rVuTVfUexl38Np2R2dJYH9nZYwBrotPuXd7n2fHyQIW
NniZflA03gkmvBBFYQJADftQ5+jabFxXkqwZsrsvtG+Ji53BZrLrczFxgPyGVfUF
A1pyQE3M6SykYjp+S3Zg6eS+yKE06guecEVhTQtwBA==
-----END RSA PRIVATE KEY-----
Loading

0 comments on commit ec2f688

Please sign in to comment.