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

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

Issue 2595723002: Allow CertNetFetcher to be shutdown from the network thread (Closed)
Patch Set: eroman comments Created 3 years, 11 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/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"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 net::CertPathBuilder path_builder(target_cert, &trust_store, 274 net::CertPathBuilder path_builder(target_cert, &trust_store,
275 &signature_policy, time, &result); 275 &signature_policy, time, &result);
276 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source); 276 path_builder.AddCertIssuerSource(&intermediate_cert_issuer_source);
277 #if defined(USE_NSS_CERTS) 277 #if defined(USE_NSS_CERTS)
278 net::CertIssuerSourceNSS cert_issuer_source_nss; 278 net::CertIssuerSourceNSS cert_issuer_source_nss;
279 path_builder.AddCertIssuerSource(&cert_issuer_source_nss); 279 path_builder.AddCertIssuerSource(&cert_issuer_source_nss);
280 #endif 280 #endif
281 281
282 // Initialize an AIA fetcher, that uses a separate thread for running the 282 // Initialize an AIA fetcher, that uses a separate thread for running the
283 // networking message loop. 283 // networking message loop.
284 // TODO(estark): update this code to use the new CertNetFetcher
285 // interface that takes a URLRequestContext*.
286 #if 0
284 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); 287 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
285 base::Thread thread("network_thread"); 288 base::Thread thread("network_thread");
286 CHECK(thread.StartWithOptions(options)); 289 CHECK(thread.StartWithOptions(options));
287 scoped_refptr<URLRequestContextGetterForAia> url_request_context_getter( 290 scoped_refptr<URLRequestContextGetterForAia> url_request_context_getter(
288 new URLRequestContextGetterForAia(thread.task_runner())); 291 new URLRequestContextGetterForAia(thread.task_runner()));
289 auto cert_net_fetcher = 292 auto cert_net_fetcher =
290 CreateCertNetFetcher(url_request_context_getter.get()); 293 CreateCertNetFetcher(url_request_context_getter.get());
291 net::CertIssuerSourceAia aia_cert_issuer_source(cert_net_fetcher.get()); 294 net::CertIssuerSourceAia aia_cert_issuer_source(cert_net_fetcher.get());
292 path_builder.AddCertIssuerSource(&aia_cert_issuer_source); 295 path_builder.AddCertIssuerSource(&aia_cert_issuer_source);
293 296
294 // Run the path builder. 297 // Run the path builder.
295 path_builder.Run(); 298 path_builder.Run();
296 299
297 // Stop the temporary network thread.. 300 // Stop the temporary network thread..
298 url_request_context_getter->ShutDown(); 301 url_request_context_getter->ShutDown();
299 thread.Stop(); 302 thread.Stop();
303 #endif
300 304
301 // TODO(crbug.com/634443): Display any errors/warnings associated with path 305 // TODO(crbug.com/634443): Display any errors/warnings associated with path
302 // building that were not part of a particular 306 // building that were not part of a particular
303 // PathResult. 307 // PathResult.
304 std::cout << "CertPathBuilder result: " 308 std::cout << "CertPathBuilder result: "
305 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n"; 309 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n";
306 310
307 for (size_t i = 0; i < result.paths.size(); ++i) { 311 for (size_t i = 0; i < result.paths.size(); ++i) {
308 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index); 312 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index);
309 } 313 }
310 314
311 // TODO(mattm): add flag to dump all paths, not just the final one? 315 // TODO(mattm): add flag to dump all paths, not just the final one?
312 if (!dump_prefix_path.empty() && result.paths.size()) { 316 if (!dump_prefix_path.empty() && result.paths.size()) {
313 if (!DumpParsedCertificateChain( 317 if (!DumpParsedCertificateChain(
314 dump_prefix_path.AddExtension( 318 dump_prefix_path.AddExtension(
315 FILE_PATH_LITERAL(".CertPathBuilder.pem")), 319 FILE_PATH_LITERAL(".CertPathBuilder.pem")),
316 result.paths[result.best_result_index]->path)) { 320 result.paths[result.best_result_index]->path)) {
317 return false; 321 return false;
318 } 322 }
319 } 323 }
320 324
321 return result.HasValidPath(); 325 return result.HasValidPath();
322 } 326 }
OLDNEW
« net/cert_net/cert_net_fetcher_impl.cc ('K') | « net/test/url_request/url_request_hanging_read_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698