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

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: tweak comments Created 3 years, 12 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0); 284 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
285 base::Thread thread("network_thread"); 285 base::Thread thread("network_thread");
286 CHECK(thread.StartWithOptions(options)); 286 CHECK(thread.StartWithOptions(options));
287
287 scoped_refptr<URLRequestContextGetterForAia> url_request_context_getter( 288 scoped_refptr<URLRequestContextGetterForAia> url_request_context_getter(
288 new URLRequestContextGetterForAia(thread.task_runner())); 289 new URLRequestContextGetterForAia(thread.task_runner()));
290 // Create a CertNetFetcher to be initialized on the network thread.
289 auto cert_net_fetcher = 291 auto cert_net_fetcher =
290 CreateCertNetFetcher(url_request_context_getter.get()); 292 CreateCertNetFetcherOnCallerThread(url_request_context_getter.get());
291 net::CertIssuerSourceAia aia_cert_issuer_source(cert_net_fetcher.get()); 293 net::CertIssuerSourceAia aia_cert_issuer_source(cert_net_fetcher.get());
eroman 2017/01/03 20:42:38 net::CertIssuerSourceAia should be updated to hold
estark 2017/01/05 19:08:40 Done.
292 path_builder.AddCertIssuerSource(&aia_cert_issuer_source); 294 path_builder.AddCertIssuerSource(&aia_cert_issuer_source);
293 295
294 // Run the path builder. 296 // Run the path builder.
295 path_builder.Run(); 297 path_builder.Run();
296 298
297 // Stop the temporary network thread.. 299 // Stop the temporary network thread.
298 url_request_context_getter->ShutDown(); 300 url_request_context_getter->ShutDown();
299 thread.Stop(); 301 thread.Stop();
300 302
301 // TODO(crbug.com/634443): Display any errors/warnings associated with path 303 // TODO(crbug.com/634443): Display any errors/warnings associated with path
302 // building that were not part of a particular 304 // building that were not part of a particular
303 // PathResult. 305 // PathResult.
304 std::cout << "CertPathBuilder result: " 306 std::cout << "CertPathBuilder result: "
305 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n"; 307 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n";
306 308
307 for (size_t i = 0; i < result.paths.size(); ++i) { 309 for (size_t i = 0; i < result.paths.size(); ++i) {
308 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index); 310 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index);
309 } 311 }
310 312
311 // TODO(mattm): add flag to dump all paths, not just the final one? 313 // TODO(mattm): add flag to dump all paths, not just the final one?
312 if (!dump_prefix_path.empty() && result.paths.size()) { 314 if (!dump_prefix_path.empty() && result.paths.size()) {
313 if (!DumpParsedCertificateChain( 315 if (!DumpParsedCertificateChain(
314 dump_prefix_path.AddExtension( 316 dump_prefix_path.AddExtension(
315 FILE_PATH_LITERAL(".CertPathBuilder.pem")), 317 FILE_PATH_LITERAL(".CertPathBuilder.pem")),
316 result.paths[result.best_result_index]->path)) { 318 result.paths[result.best_result_index]->path)) {
317 return false; 319 return false;
318 } 320 }
319 } 321 }
320 322
321 return result.HasValidPath(); 323 return result.HasValidPath();
322 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698