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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 8878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8889 // insert xyz | 8889 // insert xyz |
8890 | 8890 |
8891 EXPECT_EQ(1, d.response_started_count()); | 8891 EXPECT_EQ(1, d.response_started_count()); |
8892 AssertTwoDistinctSessionsInserted(d.data_received()); | 8892 AssertTwoDistinctSessionsInserted(d.data_received()); |
8893 } | 8893 } |
8894 } | 8894 } |
8895 | 8895 |
8896 // This the fingerprint of the "Testing CA" certificate used by the testserver. | 8896 // This the fingerprint of the "Testing CA" certificate used by the testserver. |
8897 // See net/data/ssl/certificates/ocsp-test-root.pem. | 8897 // See net/data/ssl/certificates/ocsp-test-root.pem. |
8898 static const SHA1HashValue kOCSPTestCertFingerprint = {{ | 8898 static const SHA1HashValue kOCSPTestCertFingerprint = {{ |
8899 0xa7, 0xea, 0x4b, 0x0d, 0x13, 0xc1, 0x63, 0xbf, 0xb8, 0x4e, | 8899 0x80, 0x37, 0xe7, 0xee, 0x12, 0x19, 0xeb, 0x10, 0x79, 0x36, |
8900 0x9a, 0xaf, 0x33, 0x05, 0xb0, 0x8f, 0x9c, 0xbe, 0x23, 0xe9, | 8900 0x00, 0x48, 0x57, 0x5a, 0xa6, 0x1e, 0x2b, 0x24, 0x1a, 0xd7, |
8901 }}; | 8901 }}; |
8902 | 8902 |
8903 // This is the SHA256, SPKI hash of the "Testing CA" certificate used by the | 8903 // This is the SHA256, SPKI hash of the "Testing CA" certificate used by the |
8904 // testserver. | 8904 // testserver. |
8905 static const SHA256HashValue kOCSPTestCertSPKI = { { | 8905 static const SHA256HashValue kOCSPTestCertSPKI = {{ |
8906 0xee, 0xe6, 0x51, 0x2d, 0x4c, 0xfa, 0xf7, 0x3e, | 8906 0x05, 0xa8, 0xf6, 0xfd, 0x8e, 0x10, 0xfe, 0x92, 0x2f, 0x22, 0x75, |
8907 0x6c, 0xd8, 0xca, 0x67, 0xed, 0xb5, 0x5d, 0x49, | 8907 0x46, 0x40, 0xf4, 0xc4, 0x57, 0x06, 0x0d, 0x95, 0xfd, 0x60, 0x31, |
8908 0x76, 0xe1, 0x52, 0xa7, 0x6e, 0x0e, 0xa0, 0x74, | 8908 0x3b, 0xf3, 0xfc, 0x12, 0x47, 0xe7, 0x66, 0x1a, 0x82, 0xa3, |
8909 0x09, 0x75, 0xe6, 0x23, 0x24, 0xbd, 0x1b, 0x28, | 8909 }}; |
8910 } }; | |
8911 | 8910 |
8912 // This is the policy OID contained in the certificates that testserver | 8911 // This is the policy OID contained in the certificates that testserver |
8913 // generates. | 8912 // generates. |
8914 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1"; | 8913 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1"; |
8915 | 8914 |
8916 class HTTPSOCSPTest : public HTTPSRequestTest { | 8915 class HTTPSOCSPTest : public HTTPSRequestTest { |
8917 public: | 8916 public: |
8918 HTTPSOCSPTest() | 8917 HTTPSOCSPTest() |
8919 : context_(true), | 8918 : context_(true), |
8920 ev_test_policy_( | 8919 ev_test_policy_( |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9562 EXPECT_EQ(test.response_status, ssl_info.ocsp_result.response_status); | 9561 EXPECT_EQ(test.response_status, ssl_info.ocsp_result.response_status); |
9563 | 9562 |
9564 if (test.has_revocation_status) | 9563 if (test.has_revocation_status) |
9565 EXPECT_EQ(test.cert_status, ssl_info.ocsp_result.revocation_status); | 9564 EXPECT_EQ(test.cert_status, ssl_info.ocsp_result.revocation_status); |
9566 } | 9565 } |
9567 | 9566 |
9568 INSTANTIATE_TEST_CASE_P(OCSPVerify, | 9567 INSTANTIATE_TEST_CASE_P(OCSPVerify, |
9569 HTTPSOCSPVerifyTest, | 9568 HTTPSOCSPVerifyTest, |
9570 testing::ValuesIn(kOCSPVerifyData)); | 9569 testing::ValuesIn(kOCSPVerifyData)); |
9571 | 9570 |
9571 static bool SystemSupportsAIA() { | |
9572 #if defined(OS_ANDROID) | |
9573 return false; | |
9574 #else | |
9575 return true; | |
9576 #endif | |
9577 } | |
9578 | |
9579 class HTTPSAIATest | |
9580 : public HTTPSOCSPTest, | |
9581 public testing::WithParamInterface<::testing::tuple<bool, bool>> { | |
9582 public: | |
9583 void SetupContext() override { | |
9584 context_.set_ssl_config_service(new TestSSLConfigService( | |
9585 ::testing::get<0>(GetParam()) /* check for EV */, | |
9586 ::testing::get<1>(GetParam()) /* online revocation checking */, | |
9587 false /* require rev. checking for local anchors */, | |
9588 false /* token binding enabled */)); | |
9589 } | |
9590 }; | |
9591 | |
9592 TEST_P(HTTPSAIATest, AIAFetching) { | |
9593 SpawnedTestServer::SSLOptions ssl_options( | |
9594 SpawnedTestServer::SSLOptions::CERT_AUTO_AIA_INTERMEDIATE); | |
9595 SpawnedTestServer test_server( | |
9596 SpawnedTestServer::TYPE_HTTPS, ssl_options, | |
9597 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | |
9598 ASSERT_TRUE(test_server.Start()); | |
9599 | |
9600 TestDelegate d; | |
9601 d.set_allow_certificate_errors(true); | |
9602 std::unique_ptr<URLRequest> r(context_.CreateRequest( | |
9603 test_server.GetURL("/defaultresponse"), DEFAULT_PRIORITY, &d)); | |
9604 | |
9605 r->Start(); | |
9606 EXPECT_TRUE(r->is_pending()); | |
9607 | |
9608 base::RunLoop().Run(); | |
9609 | |
9610 EXPECT_EQ(1, d.response_started_count()); | |
9611 | |
9612 CertStatus cert_status = r->ssl_info().cert_status; | |
9613 if (SystemSupportsAIA()) { | |
9614 EXPECT_EQ(OK, d.request_status()); | |
9615 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); | |
9616 ASSERT_TRUE(r->ssl_info().cert); | |
9617 EXPECT_EQ(2u, r->ssl_info().cert->GetIntermediateCertificates().size()); | |
9618 } else { | |
9619 EXPECT_EQ(CERT_STATUS_AUTHORITY_INVALID, | |
9620 cert_status & CERT_STATUS_ALL_ERRORS); | |
9621 } | |
9622 ASSERT_TRUE(r->ssl_info().unverified_cert); | |
9623 EXPECT_EQ( | |
9624 0u, r->ssl_info().unverified_cert->GetIntermediateCertificates().size()); | |
9625 } | |
9626 | |
9627 // Run AIA unittests with different combinations of revocation checking flags. | |
9628 // In theory revocation checks should have no effect on AIA fetching, but on | |
9629 // some OSX versions that is not the case. | |
davidben
2016/10/21 22:42:27
Just to confirm, you mean that on OSX versions the
mattm
2016/10/21 23:24:20
Well.. on sierra I discovered the previous workaro
davidben
2016/10/22 01:28:18
Ah, I see. I dunno if we try to avoid checking in
| |
9630 INSTANTIATE_TEST_CASE_P(InstantiationName, | |
9631 HTTPSAIATest, | |
9632 ::testing::Combine(::testing::ValuesIn({false, true}), | |
9633 ::testing::ValuesIn({false, true}))); | |
9634 | |
9572 class HTTPSHardFailTest : public HTTPSOCSPTest { | 9635 class HTTPSHardFailTest : public HTTPSOCSPTest { |
9573 protected: | 9636 protected: |
9574 void SetupContext() override { | 9637 void SetupContext() override { |
9575 context_.set_ssl_config_service(new TestSSLConfigService( | 9638 context_.set_ssl_config_service(new TestSSLConfigService( |
9576 false /* check for EV */, false /* online revocation checking */, | 9639 false /* check for EV */, false /* online revocation checking */, |
9577 true /* require rev. checking for local | 9640 true /* require rev. checking for local |
9578 anchors */, | 9641 anchors */, |
9579 false /* token binding enabled */)); | 9642 false /* token binding enabled */)); |
9580 } | 9643 } |
9581 }; | 9644 }; |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10218 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10281 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
10219 | 10282 |
10220 req->Start(); | 10283 req->Start(); |
10221 req->Cancel(); | 10284 req->Cancel(); |
10222 base::RunLoop().RunUntilIdle(); | 10285 base::RunLoop().RunUntilIdle(); |
10223 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 10286 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
10224 EXPECT_EQ(0, d.received_redirect_count()); | 10287 EXPECT_EQ(0, d.received_redirect_count()); |
10225 } | 10288 } |
10226 | 10289 |
10227 } // namespace net | 10290 } // namespace net |
OLD | NEW |