| Index: net/base/x509_certificate_unittest.cc
|
| diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc
|
| index cf779b79f869e8ed326fb94675b896892ee067e6..2badf8bb8405b5542e75f515a01c400713d7e487 100644
|
| --- a/net/base/x509_certificate_unittest.cc
|
| +++ b/net/base/x509_certificate_unittest.cc
|
| @@ -14,6 +14,7 @@
|
| #include "net/base/cert_status_flags.h"
|
| #include "net/base/cert_test_util.h"
|
| #include "net/base/cert_verify_result.h"
|
| +#include "net/base/crl_set.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/base/test_certificate_data.h"
|
| #include "net/base/test_root_certs.h"
|
| @@ -1383,6 +1384,106 @@ TEST(X509CertificateTest, GetDEREncoded) {
|
| }
|
| #endif
|
|
|
| +#if defined(USE_NSS)
|
| +static const uint8 kCRLSetThawteSPKIBlocked[] = {
|
| + 0x8e, 0x00, 0x7b, 0x22, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a,
|
| + 0x30, 0x2c, 0x22, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
|
| + 0x65, 0x22, 0x3a, 0x22, 0x43, 0x52, 0x4c, 0x53, 0x65, 0x74, 0x22, 0x2c, 0x22,
|
| + 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x30, 0x2c, 0x22,
|
| + 0x44, 0x65, 0x6c, 0x74, 0x61, 0x46, 0x72, 0x6f, 0x6d, 0x22, 0x3a, 0x30, 0x2c,
|
| + 0x22, 0x4e, 0x75, 0x6d, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3a,
|
| + 0x30, 0x2c, 0x22, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x53, 0x50, 0x4b,
|
| + 0x49, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x36, 0x58, 0x36, 0x4d, 0x78, 0x52, 0x37,
|
| + 0x58, 0x70, 0x4d, 0x51, 0x4b, 0x78, 0x49, 0x41, 0x39, 0x50, 0x6a, 0x36, 0x37,
|
| + 0x36, 0x38, 0x76, 0x74, 0x55, 0x6b, 0x6b, 0x7a, 0x48, 0x79, 0x7a, 0x41, 0x6f,
|
| + 0x6d, 0x6f, 0x4f, 0x68, 0x4b, 0x55, 0x6e, 0x7a, 0x73, 0x55, 0x3d, 0x22, 0x5d,
|
| + 0x7d,
|
| +};
|
| +
|
| +static const uint8 kCRLSetThawteSerialBlocked[] = {
|
| + 0x60, 0x00, 0x7b, 0x22, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a,
|
| + 0x30, 0x2c, 0x22, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
|
| + 0x65, 0x22, 0x3a, 0x22, 0x43, 0x52, 0x4c, 0x53, 0x65, 0x74, 0x22, 0x2c, 0x22,
|
| + 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x30, 0x2c, 0x22,
|
| + 0x44, 0x65, 0x6c, 0x74, 0x61, 0x46, 0x72, 0x6f, 0x6d, 0x22, 0x3a, 0x30, 0x2c,
|
| + 0x22, 0x4e, 0x75, 0x6d, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3a,
|
| + 0x31, 0x2c, 0x22, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x53, 0x50, 0x4b,
|
| + 0x49, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0xb1, 0x12, 0x41, 0x42, 0xa5, 0xa1,
|
| + 0xa5, 0xa2, 0x88, 0x19, 0xc7, 0x35, 0x34, 0x0e, 0xff, 0x8c, 0x9e, 0x2f, 0x81,
|
| + 0x68, 0xfe, 0xe3, 0xba, 0x18, 0x7f, 0x25, 0x3b, 0xc1, 0xa3, 0x92, 0xd7, 0xe2,
|
| + 0x01, 0x00, 0x00, 0x00, 0x04, 0x30, 0x00, 0x00, 0x02,
|
| +};
|
| +
|
| +static const uint8 kCRLSetGoogleSerialBlocked[] = {
|
| + 0x60, 0x00, 0x7b, 0x22, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a,
|
| + 0x30, 0x2c, 0x22, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
|
| + 0x65, 0x22, 0x3a, 0x22, 0x43, 0x52, 0x4c, 0x53, 0x65, 0x74, 0x22, 0x2c, 0x22,
|
| + 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x3a, 0x30, 0x2c, 0x22,
|
| + 0x44, 0x65, 0x6c, 0x74, 0x61, 0x46, 0x72, 0x6f, 0x6d, 0x22, 0x3a, 0x30, 0x2c,
|
| + 0x22, 0x4e, 0x75, 0x6d, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3a,
|
| + 0x31, 0x2c, 0x22, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x53, 0x50, 0x4b,
|
| + 0x49, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0xe9, 0x7e, 0x8c, 0xc5, 0x1e, 0xd7,
|
| + 0xa4, 0xc4, 0x0a, 0xc4, 0x80, 0x3d, 0x3e, 0x3e, 0xbb, 0xeb, 0xcb, 0xed, 0x52,
|
| + 0x49, 0x33, 0x1f, 0x2c, 0xc0, 0xa2, 0x6a, 0x0e, 0x84, 0xa5, 0x27, 0xce, 0xc5,
|
| + 0x01, 0x00, 0x00, 0x00, 0x10, 0x4f, 0x9d, 0x96, 0xd9, 0x66, 0xb0, 0x99, 0x2b,
|
| + 0x54, 0xc2, 0x95, 0x7c, 0xb4, 0x15, 0x7d, 0x4d,
|
| +};
|
| +
|
| +// Test that CRLSets are effective in making a certificate appear to be
|
| +// revoked.
|
| +TEST(X509CertificateTest, CRLSet) {
|
| + CertificateList certs = CreateCertificateListFromFile(
|
| + GetTestCertsDirectory(),
|
| + "googlenew.chain.pem",
|
| + X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
|
| +
|
| + X509Certificate::OSCertHandles intermediates;
|
| + intermediates.push_back(certs[1]->os_cert_handle());
|
| +
|
| + scoped_refptr<X509Certificate> google_full_chain =
|
| + X509Certificate::CreateFromHandle(certs[0]->os_cert_handle(),
|
| + intermediates);
|
| +
|
| + CertVerifyResult verify_result;
|
| + int error = google_full_chain->Verify(
|
| + "www.google.com", 0, NULL, &verify_result);
|
| + EXPECT_EQ(OK, error);
|
| +
|
| + // First test blocking by SPKI.
|
| + base::StringPiece crl_set_bytes(
|
| + reinterpret_cast<const char*>(kCRLSetThawteSPKIBlocked),
|
| + sizeof(kCRLSetThawteSPKIBlocked));
|
| + scoped_refptr<CRLSet> crl_set;
|
| + ASSERT_TRUE(CRLSet::Parse(crl_set_bytes, &crl_set));
|
| +
|
| + error = google_full_chain->Verify(
|
| + "www.google.com", 0, crl_set.get(), &verify_result);
|
| + EXPECT_EQ(ERR_CERT_REVOKED, error);
|
| +
|
| + // Second, test revocation by serial number of a cert directly under the
|
| + // root.
|
| + crl_set_bytes = base::StringPiece(
|
| + reinterpret_cast<const char*>(kCRLSetThawteSerialBlocked),
|
| + sizeof(kCRLSetThawteSerialBlocked));
|
| + ASSERT_TRUE(CRLSet::Parse(crl_set_bytes, &crl_set));
|
| +
|
| + error = google_full_chain->Verify(
|
| + "www.google.com", 0, crl_set.get(), &verify_result);
|
| + EXPECT_EQ(ERR_CERT_REVOKED, error);
|
| +
|
| + // Lastly, test revocation by serial number of a certificate not under the
|
| + // root.
|
| + crl_set_bytes = base::StringPiece(
|
| + reinterpret_cast<const char*>(kCRLSetGoogleSerialBlocked),
|
| + sizeof(kCRLSetGoogleSerialBlocked));
|
| + ASSERT_TRUE(CRLSet::Parse(crl_set_bytes, &crl_set));
|
| +
|
| + error = google_full_chain->Verify(
|
| + "www.google.com", 0, crl_set.get(), &verify_result);
|
| + EXPECT_EQ(ERR_CERT_REVOKED, error);
|
| +}
|
| +#endif
|
| +
|
| class X509CertificateParseTest
|
| : public testing::TestWithParam<CertificateFormatTestData> {
|
| public:
|
|
|