OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/time/time.h" | 5 #include "base/time/time.h" |
6 #include "components/cast_certificate/cast_cert_validator.h" | 6 #include "components/cast_certificate/cast_cert_validator.h" |
7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" | 7 #include "components/cast_certificate/cast_cert_validator_test_helpers.h" |
8 #include "components/cast_certificate/cast_crl.h" | 8 #include "components/cast_certificate/cast_crl.h" |
9 #include "components/cast_certificate/proto/test_suite.pb.h" | 9 #include "components/cast_certificate/proto/test_suite.pb.h" |
| 10 #include "net/cert/internal/cert_errors.h" |
10 #include "net/cert/internal/trust_store_in_memory.h" | 11 #include "net/cert/internal/trust_store_in_memory.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
13 namespace cast_certificate { | 14 namespace cast_certificate { |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Creates a trust store using the test roots encoded in the PEM file at |path|. | 17 // Creates a trust store using the test roots encoded in the PEM file at |path|. |
17 std::unique_ptr<net::TrustStoreInMemory> CreateTrustStoreFromFile( | 18 std::unique_ptr<net::TrustStoreInMemory> CreateTrustStoreFromFile( |
18 const std::string& path) { | 19 const std::string& path) { |
19 std::unique_ptr<net::TrustStoreInMemory> trust_store( | 20 std::unique_ptr<net::TrustStoreInMemory> trust_store( |
20 new net::TrustStoreInMemory()); | 21 new net::TrustStoreInMemory()); |
21 const auto trusted_test_roots = | 22 const auto trusted_test_roots = |
22 cast_certificate::testing::ReadCertificateChainFromFile(path); | 23 cast_certificate::testing::ReadCertificateChainFromFile(path); |
23 for (const auto& trusted_root : trusted_test_roots) { | 24 for (const auto& trusted_root : trusted_test_roots) { |
| 25 net::CertErrors errors; |
24 scoped_refptr<net::ParsedCertificate> cert( | 26 scoped_refptr<net::ParsedCertificate> cert( |
25 net::ParsedCertificate::CreateFromCertificateCopy(trusted_root, {})); | 27 net::ParsedCertificate::Create(trusted_root, {}, &errors)); |
26 EXPECT_TRUE(cert); | 28 EXPECT_TRUE(cert) << errors.ToDebugString(); |
27 scoped_refptr<net::TrustAnchor> anchor = | 29 scoped_refptr<net::TrustAnchor> anchor = |
28 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); | 30 net::TrustAnchor::CreateFromCertificateWithConstraints(std::move(cert)); |
29 trust_store->AddTrustAnchor(std::move(anchor)); | 31 trust_store->AddTrustAnchor(std::move(anchor)); |
30 } | 32 } |
31 return trust_store; | 33 return trust_store; |
32 } | 34 } |
33 | 35 |
34 // Converts uint64_t unix timestamp in seconds to base::Time. | 36 // Converts uint64_t unix timestamp in seconds to base::Time. |
35 base::Time ConvertUnixTimestampSeconds(uint64_t time) { | 37 base::Time ConvertUnixTimestampSeconds(uint64_t time) { |
36 return base::Time::UnixEpoch() + | 38 return base::Time::UnixEpoch() + |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 251 } |
250 } | 252 } |
251 | 253 |
252 TEST(CastCertificateTest, TestSuite1) { | 254 TEST(CastCertificateTest, TestSuite1) { |
253 RunTestSuite("testsuite/testsuite1.pb"); | 255 RunTestSuite("testsuite/testsuite1.pb"); |
254 } | 256 } |
255 | 257 |
256 } // namespace | 258 } // namespace |
257 | 259 |
258 } // namespace cast_certificate | 260 } // namespace cast_certificate |
OLD | NEW |