Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: net/cert/internal/path_builder_verify_certificate_chain_unittest.cc

Issue 2832703002: Allow the TrustStore interface to return matching intermediates, and identify distrusted certs. (Closed)
Patch Set: fix cert_verify_tool Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "net/cert/internal/path_builder.h" 5 #include "net/cert/internal/path_builder.h"
6 6
7 #include "net/cert/internal/cert_issuer_source_static.h" 7 #include "net/cert/internal/cert_issuer_source_static.h"
8 #include "net/cert/internal/signature_policy.h" 8 #include "net/cert/internal/signature_policy.h"
9 #include "net/cert/internal/trust_store_in_memory.h" 9 #include "net/cert/internal/trust_store_in_memory.h"
10 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h" 10 #include "net/cert/internal/verify_certificate_chain_typed_unittest.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 namespace { 14 namespace {
15 15
16 class PathBuilderDelegate { 16 class PathBuilderDelegate {
17 public: 17 public:
18 static void Verify(const VerifyCertChainTest& test, 18 static void Verify(const VerifyCertChainTest& test,
19 const std::string& test_file_path) { 19 const std::string& test_file_path) {
20 SimpleSignaturePolicy signature_policy(1024); 20 SimpleSignaturePolicy signature_policy(1024);
21 ASSERT_FALSE(test.chain.empty()); 21 ASSERT_FALSE(test.chain.empty());
22 22
23 TrustStoreInMemory trust_store; 23 TrustStoreInMemory trust_store;
24 trust_store.AddTrustAnchor(test.trust_anchor); 24 trust_store.AddCertificate(test.chain.back(), test.last_cert_trust);
25 25
26 CertIssuerSourceStatic intermediate_cert_issuer_source; 26 CertIssuerSourceStatic intermediate_cert_issuer_source;
27 for (size_t i = 1; i < test.chain.size(); ++i) 27 for (size_t i = 1; i < test.chain.size(); ++i)
28 intermediate_cert_issuer_source.AddCert(test.chain[i]); 28 intermediate_cert_issuer_source.AddCert(test.chain[i]);
29 29
30 CertPathBuilder::Result result; 30 CertPathBuilder::Result result;
31 // First cert in the |chain| is the target. 31 // First cert in the |chain| is the target.
32 CertPathBuilder path_builder(test.chain.front(), &trust_store, 32 CertPathBuilder path_builder(test.chain.front(), &trust_store,
33 &signature_policy, test.time, test.key_purpose, 33 &signature_policy, test.time, test.key_purpose,
34 &result); 34 &result);
35 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); 35 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source);
36 36
37 path_builder.Run(); 37 path_builder.Run();
38 EXPECT_EQ(test.expected_result, result.HasValidPath()); 38 EXPECT_EQ(test.expected_result, result.HasValidPath());
39 } 39 }
40 }; 40 };
41 41
42 } // namespace 42 } // namespace
43 43
44 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, 44 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder,
45 VerifyCertificateChainSingleRootTest, 45 VerifyCertificateChainSingleRootTest,
46 PathBuilderDelegate); 46 PathBuilderDelegate);
47 47
48 } // namespace net 48 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698