| OLD | NEW |
| 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 Loading... |
| 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); |
| 296 #endif |
| 293 | 297 |
| 294 // Run the path builder. | 298 // Run the path builder. |
| 295 path_builder.Run(); | 299 path_builder.Run(); |
| 296 | 300 |
| 301 #if 0 |
| 297 // Stop the temporary network thread.. | 302 // Stop the temporary network thread.. |
| 298 url_request_context_getter->ShutDown(); | 303 url_request_context_getter->ShutDown(); |
| 299 thread.Stop(); | 304 thread.Stop(); |
| 305 #endif |
| 300 | 306 |
| 301 // TODO(crbug.com/634443): Display any errors/warnings associated with path | 307 // TODO(crbug.com/634443): Display any errors/warnings associated with path |
| 302 // building that were not part of a particular | 308 // building that were not part of a particular |
| 303 // PathResult. | 309 // PathResult. |
| 304 std::cout << "CertPathBuilder result: " | 310 std::cout << "CertPathBuilder result: " |
| 305 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n"; | 311 << (result.HasValidPath() ? "SUCCESS" : "FAILURE") << "\n"; |
| 306 | 312 |
| 307 for (size_t i = 0; i < result.paths.size(); ++i) { | 313 for (size_t i = 0; i < result.paths.size(); ++i) { |
| 308 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index); | 314 PrintResultPath(result.paths[i].get(), i, i == result.best_result_index); |
| 309 } | 315 } |
| 310 | 316 |
| 311 // TODO(mattm): add flag to dump all paths, not just the final one? | 317 // TODO(mattm): add flag to dump all paths, not just the final one? |
| 312 if (!dump_prefix_path.empty() && result.paths.size()) { | 318 if (!dump_prefix_path.empty() && result.paths.size()) { |
| 313 if (!DumpParsedCertificateChain( | 319 if (!DumpParsedCertificateChain( |
| 314 dump_prefix_path.AddExtension( | 320 dump_prefix_path.AddExtension( |
| 315 FILE_PATH_LITERAL(".CertPathBuilder.pem")), | 321 FILE_PATH_LITERAL(".CertPathBuilder.pem")), |
| 316 result.paths[result.best_result_index]->path)) { | 322 result.paths[result.best_result_index]->path)) { |
| 317 return false; | 323 return false; |
| 318 } | 324 } |
| 319 } | 325 } |
| 320 | 326 |
| 321 return result.HasValidPath(); | 327 return result.HasValidPath(); |
| 322 } | 328 } |
| OLD | NEW |