OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 std::vector<base::StringPiece> crl_urls; | 485 std::vector<base::StringPiece> crl_urls; |
486 EXPECT_TRUE(asn1::ExtractCRLURLsFromDERCert(derBytes, &crl_urls)); | 486 EXPECT_TRUE(asn1::ExtractCRLURLsFromDERCert(derBytes, &crl_urls)); |
487 | 487 |
488 EXPECT_EQ(1u, crl_urls.size()); | 488 EXPECT_EQ(1u, crl_urls.size()); |
489 if (crl_urls.size() > 0) { | 489 if (crl_urls.size() > 0) { |
490 EXPECT_EQ("http://SVRSecure-G3-crl.verisign.com/SVRSecureG3.crl", | 490 EXPECT_EQ("http://SVRSecure-G3-crl.verisign.com/SVRSecureG3.crl", |
491 crl_urls[0].as_string()); | 491 crl_urls[0].as_string()); |
492 } | 492 } |
493 } | 493 } |
494 | 494 |
| 495 TEST(X509CertificateTest, HasTLSFeatureExtension) { |
| 496 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 497 scoped_refptr<X509Certificate> cert = |
| 498 ImportCertFromFile(certs_dir, "tls_feature_extension.pem"); |
| 499 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get()); |
| 500 |
| 501 std::string derBytes; |
| 502 EXPECT_TRUE( |
| 503 X509Certificate::GetDEREncoded(cert->os_cert_handle(), &derBytes)); |
| 504 |
| 505 EXPECT_TRUE(asn1::HasTLSFeatureExtension(derBytes)); |
| 506 } |
| 507 |
| 508 TEST(X509CertificateTest, DoesNotHaveTLSFeatureExtension) { |
| 509 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 510 scoped_refptr<X509Certificate> cert = |
| 511 ImportCertFromFile(certs_dir, "ok_cert.pem"); |
| 512 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get()); |
| 513 |
| 514 std::string derBytes; |
| 515 EXPECT_TRUE( |
| 516 X509Certificate::GetDEREncoded(cert->os_cert_handle(), &derBytes)); |
| 517 |
| 518 EXPECT_FALSE(asn1::HasTLSFeatureExtension(derBytes)); |
| 519 } |
| 520 |
495 // Tests X509CertificateCache via X509Certificate::CreateFromHandle. We | 521 // Tests X509CertificateCache via X509Certificate::CreateFromHandle. We |
496 // call X509Certificate::CreateFromHandle several times and observe whether | 522 // call X509Certificate::CreateFromHandle several times and observe whether |
497 // it returns a cached or new OSCertHandle. | 523 // it returns a cached or new OSCertHandle. |
498 TEST(X509CertificateTest, Cache) { | 524 TEST(X509CertificateTest, Cache) { |
499 X509Certificate::OSCertHandle google_cert_handle; | 525 X509Certificate::OSCertHandle google_cert_handle; |
500 X509Certificate::OSCertHandle thawte_cert_handle; | 526 X509Certificate::OSCertHandle thawte_cert_handle; |
501 | 527 |
502 // Add a single certificate to the certificate cache. | 528 // Add a single certificate to the certificate cache. |
503 google_cert_handle = X509Certificate::CreateOSCertHandleFromBytes( | 529 google_cert_handle = X509Certificate::CreateOSCertHandleFromBytes( |
504 reinterpret_cast<const char*>(google_der), sizeof(google_der)); | 530 reinterpret_cast<const char*>(google_der), sizeof(google_der)); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 &actual_type); | 1194 &actual_type); |
1169 | 1195 |
1170 EXPECT_EQ(data.expected_bits, actual_bits); | 1196 EXPECT_EQ(data.expected_bits, actual_bits); |
1171 EXPECT_EQ(data.expected_type, actual_type); | 1197 EXPECT_EQ(data.expected_type, actual_type); |
1172 } | 1198 } |
1173 | 1199 |
1174 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, | 1200 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, |
1175 testing::ValuesIn(kPublicKeyInfoTestData)); | 1201 testing::ValuesIn(kPublicKeyInfoTestData)); |
1176 | 1202 |
1177 } // namespace net | 1203 } // namespace net |
OLD | NEW |