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

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

Issue 2126803004: WIP: NSS trust store integration for path builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-command-line-path-builder-add_certpathbuilder
Patch Set: . Created 4 years, 4 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
« no previous file with comments | « net/cert/internal/path_builder_unittest.cc ('k') | net/cert/internal/test_helpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 9 #include "net/cert/internal/trust_store_static.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 ParsedCertificateList& chain, 18 static void Verify(const ParsedCertificateList& chain,
19 const ParsedCertificateList& roots, 19 const ParsedCertificateList& roots,
20 const der::GeneralizedTime& time, 20 const der::GeneralizedTime& time,
21 bool expected_result) { 21 bool expected_result) {
22 SimpleSignaturePolicy signature_policy(1024); 22 SimpleSignaturePolicy signature_policy(1024);
23 ASSERT_FALSE(chain.empty()); 23 ASSERT_FALSE(chain.empty());
24 24
25 TrustStore trust_store; 25 TrustStoreStatic trust_store;
26 for (const auto& root : roots) 26 CertIssuerSourceStatic cert_issuer_source;
27
28 for (const auto& root : roots) {
27 trust_store.AddTrustedCertificate(root); 29 trust_store.AddTrustedCertificate(root);
30 cert_issuer_source.AddCert(root);
31 }
28 32
29 CertIssuerSourceStatic intermediate_cert_issuer_source; 33 for (const auto& cert : chain)
30 for (size_t i = 1; i < chain.size(); ++i) 34 cert_issuer_source.AddCert(cert);
31 intermediate_cert_issuer_source.AddCert(chain[i]);
32 35
33 CertPathBuilder::Result result; 36 CertPathBuilder::Result result;
34 // First cert in the |chain| is the target. 37 // First cert in the |chain| is the target.
35 CertPathBuilder path_builder(chain.front(), &trust_store, &signature_policy, 38 CertPathBuilder path_builder(chain.front(), &signature_policy, time,
36 time, &result); 39 &result);
37 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); 40 path_builder.AddTrustStore(&trust_store);
41 path_builder.AddCertIssuerSource(&cert_issuer_source);
38 42
39 CompletionStatus rv = path_builder.Run(base::Closure()); 43 CompletionStatus rv = path_builder.Run(base::Closure());
40 EXPECT_EQ(CompletionStatus::SYNC, rv); 44 EXPECT_EQ(CompletionStatus::SYNC, rv);
41 45
42 EXPECT_EQ(expected_result, result.is_success()); 46 EXPECT_EQ(expected_result, result.is_success());
43 } 47 }
44 }; 48 };
45 49
46 } // namespace 50 } // namespace
47 51
48 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, 52 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder,
49 VerifyCertificateChainSingleRootTest, 53 VerifyCertificateChainSingleRootTest,
50 PathBuilderDelegate); 54 PathBuilderDelegate);
51 55
52 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder, 56 INSTANTIATE_TYPED_TEST_CASE_P(PathBuilder,
53 VerifyCertificateChainNonSingleRootTest, 57 VerifyCertificateChainNonSingleRootTest,
54 PathBuilderDelegate); 58 PathBuilderDelegate);
55 59
56 } // namespace net 60 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/path_builder_unittest.cc ('k') | net/cert/internal/test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698