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

Side by Side Diff: net/tools/cert_verify_tool/verify_using_path_builder.cc

Issue 2272493002: Add TrustStoreNSS and TrustStoreCollection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-trust-store-interface3-nss
Patch Set: rebase Created 4 years, 3 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/net.gypi ('k') | no next file » | 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/tools/cert_verify_tool/verify_using_path_builder.h" 5 #include "net/tools/cert_verify_tool/verify_using_path_builder.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "crypto/sha2.h" 12 #include "crypto/sha2.h"
13 #include "net/base/test_completion_callback.h" 13 #include "net/base/test_completion_callback.h"
14 #include "net/cert/internal/cert_issuer_source_aia.h" 14 #include "net/cert/internal/cert_issuer_source_aia.h"
15 #include "net/cert/internal/cert_issuer_source_static.h" 15 #include "net/cert/internal/cert_issuer_source_static.h"
16 #include "net/cert/internal/parse_name.h" 16 #include "net/cert/internal/parse_name.h"
17 #include "net/cert/internal/parsed_certificate.h" 17 #include "net/cert/internal/parsed_certificate.h"
18 #include "net/cert/internal/path_builder.h" 18 #include "net/cert/internal/path_builder.h"
19 #include "net/cert/internal/signature_policy.h" 19 #include "net/cert/internal/signature_policy.h"
20 #include "net/cert/internal/trust_store_collection.h"
20 #include "net/cert/internal/trust_store_in_memory.h" 21 #include "net/cert/internal/trust_store_in_memory.h"
21 #include "net/cert_net/cert_net_fetcher_impl.h" 22 #include "net/cert_net/cert_net_fetcher_impl.h"
22 #include "net/tools/cert_verify_tool/cert_verify_tool_util.h" 23 #include "net/tools/cert_verify_tool/cert_verify_tool_util.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
24 #include "net/url_request/url_request_context_builder.h" 25 #include "net/url_request/url_request_context_builder.h"
25 26
27 #if defined(USE_NSS_CERTS)
28 #include "base/threading/thread_task_runner_handle.h"
29 #include "net/cert/internal/trust_store_nss.h"
30 #endif
31
26 #if defined(OS_LINUX) 32 #if defined(OS_LINUX)
27 #include "net/proxy/proxy_config.h" 33 #include "net/proxy/proxy_config.h"
28 #include "net/proxy/proxy_config_service_fixed.h" 34 #include "net/proxy/proxy_config_service_fixed.h"
29 #endif 35 #endif
30 36
31 namespace { 37 namespace {
32 38
33 std::string GetUserAgent() { 39 std::string GetUserAgent() {
34 return "cert_verify_tool/0.1"; 40 return "cert_verify_tool/0.1";
35 } 41 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 163
158 } // namespace 164 } // namespace
159 165
160 // Verifies |target_der_cert| using CertPathBuilder. 166 // Verifies |target_der_cert| using CertPathBuilder.
161 bool VerifyUsingPathBuilder( 167 bool VerifyUsingPathBuilder(
162 const CertInput& target_der_cert, 168 const CertInput& target_der_cert,
163 const std::vector<CertInput>& intermediate_der_certs, 169 const std::vector<CertInput>& intermediate_der_certs,
164 const std::vector<CertInput>& root_der_certs, 170 const std::vector<CertInput>& root_der_certs,
165 const base::Time at_time, 171 const base::Time at_time,
166 const base::FilePath& dump_prefix_path) { 172 const base::FilePath& dump_prefix_path) {
167 std::cout << "NOTE: CertPathBuilder does not currently use OS trust settings "
168 "(--roots must be specified).\n";
169 std::cerr << "WARNING: --hostname is not yet verified with CertPathBuilder\n"; 173 std::cerr << "WARNING: --hostname is not yet verified with CertPathBuilder\n";
170 174
171 base::Time::Exploded exploded_time; 175 base::Time::Exploded exploded_time;
172 at_time.UTCExplode(&exploded_time); 176 at_time.UTCExplode(&exploded_time);
173 net::der::GeneralizedTime time = ConvertExplodedTime(exploded_time); 177 net::der::GeneralizedTime time = ConvertExplodedTime(exploded_time);
174 178
175 net::TrustStoreInMemory trust_store; 179 net::TrustStoreCollection trust_store;
180
181 net::TrustStoreInMemory trust_store_in_memory;
182 trust_store.AddTrustStoreSynchronousOnly(&trust_store_in_memory);
176 for (const auto& der_cert : root_der_certs) { 183 for (const auto& der_cert : root_der_certs) {
177 scoped_refptr<net::ParsedCertificate> cert = 184 scoped_refptr<net::ParsedCertificate> cert =
178 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert, 185 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert,
179 {}); 186 {});
180 if (!cert) 187 if (!cert)
181 PrintCertError("ERROR: ParsedCertificate failed:", der_cert); 188 PrintCertError("ERROR: ParsedCertificate failed:", der_cert);
182 else { 189 else {
183 trust_store.AddTrustAnchor( 190 trust_store_in_memory.AddTrustAnchor(
184 net::TrustAnchor::CreateFromCertificateNoConstraints(cert)); 191 net::TrustAnchor::CreateFromCertificateNoConstraints(cert));
185 } 192 }
186 } 193 }
187 194
195 #if defined(USE_NSS_CERTS)
196 net::TrustStoreNSS trust_store_nss(trustSSL,
197 base::ThreadTaskRunnerHandle::Get());
198 trust_store.SetPrimaryTrustStore(&trust_store_nss);
199 #else
200 std::cout << "NOTE: CertPathBuilder does not currently use OS trust settings "
201 "(--roots must be specified).\n";
202 #endif
203
188 net::CertIssuerSourceStatic intermediate_cert_issuer_source; 204 net::CertIssuerSourceStatic intermediate_cert_issuer_source;
189 for (const auto& der_cert : intermediate_der_certs) { 205 for (const auto& der_cert : intermediate_der_certs) {
190 scoped_refptr<net::ParsedCertificate> cert = 206 scoped_refptr<net::ParsedCertificate> cert =
191 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert, 207 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert,
192 {}); 208 {});
193 if (!cert) 209 if (!cert)
194 PrintCertError("ERROR: ParsedCertificate failed:", der_cert); 210 PrintCertError("ERROR: ParsedCertificate failed:", der_cert);
195 else 211 else
196 intermediate_cert_issuer_source.AddCert(cert); 212 intermediate_cert_issuer_source.AddCert(cert);
197 } 213 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!DumpParsedCertificateChain( 269 if (!DumpParsedCertificateChain(
254 dump_prefix_path.AddExtension( 270 dump_prefix_path.AddExtension(
255 FILE_PATH_LITERAL(".CertPathBuilder.pem")), 271 FILE_PATH_LITERAL(".CertPathBuilder.pem")),
256 result.paths[result.best_result_index]->path)) { 272 result.paths[result.best_result_index]->path)) {
257 return false; 273 return false;
258 } 274 }
259 } 275 }
260 276
261 return result.HasValidPath(); 277 return result.HasValidPath();
262 } 278 }
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698