| 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" |
| 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/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
| 15 #include "net/cert/internal/cert_issuer_source_aia.h" | 15 #include "net/cert/internal/cert_issuer_source_aia.h" |
| 16 #include "net/cert/internal/cert_issuer_source_static.h" | 16 #include "net/cert/internal/cert_issuer_source_static.h" |
| 17 #include "net/cert/internal/parse_name.h" | 17 #include "net/cert/internal/parse_name.h" |
| 18 #include "net/cert/internal/parsed_certificate.h" | 18 #include "net/cert/internal/parsed_certificate.h" |
| 19 #include "net/cert/internal/path_builder.h" | 19 #include "net/cert/internal/path_builder.h" |
| 20 #include "net/cert/internal/signature_policy.h" | 20 #include "net/cert/internal/signature_policy.h" |
| 21 #include "net/cert/internal/trust_store.h" | 21 #include "net/cert/internal/trust_store_static.h" |
| 22 #include "net/cert_net/cert_net_fetcher_impl.h" | 22 #include "net/cert_net/cert_net_fetcher_impl.h" |
| 23 #include "net/tools/cert_verify_tool/cert_verify_tool_util.h" | 23 #include "net/tools/cert_verify_tool/cert_verify_tool_util.h" |
| 24 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 25 #include "net/url_request/url_request_context_builder.h" | 25 #include "net/url_request/url_request_context_builder.h" |
| 26 | 26 |
| 27 #if defined(OS_LINUX) | 27 #if defined(OS_LINUX) |
| 28 #include "net/proxy/proxy_config.h" | 28 #include "net/proxy/proxy_config.h" |
| 29 #include "net/proxy/proxy_config_service_fixed.h" | 29 #include "net/proxy/proxy_config_service_fixed.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const base::Time at_time, | 111 const base::Time at_time, |
| 112 const base::FilePath& dump_prefix_path) { | 112 const base::FilePath& dump_prefix_path) { |
| 113 std::cout << "NOTE: CertPathBuilder does not currently use OS trust settings " | 113 std::cout << "NOTE: CertPathBuilder does not currently use OS trust settings " |
| 114 "(--roots must be specified).\n"; | 114 "(--roots must be specified).\n"; |
| 115 std::cerr << "WARNING: --hostname is not yet verified with CertPathBuilder\n"; | 115 std::cerr << "WARNING: --hostname is not yet verified with CertPathBuilder\n"; |
| 116 | 116 |
| 117 base::Time::Exploded exploded_time; | 117 base::Time::Exploded exploded_time; |
| 118 at_time.UTCExplode(&exploded_time); | 118 at_time.UTCExplode(&exploded_time); |
| 119 net::der::GeneralizedTime time = ConvertExplodedTime(exploded_time); | 119 net::der::GeneralizedTime time = ConvertExplodedTime(exploded_time); |
| 120 | 120 |
| 121 net::TrustStore trust_store; | 121 net::TrustStoreStatic trust_store; |
| 122 for (const auto& der_cert : root_der_certs) { | 122 for (const auto& der_cert : root_der_certs) { |
| 123 scoped_refptr<net::ParsedCertificate> cert = | 123 scoped_refptr<net::ParsedCertificate> cert = |
| 124 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert, | 124 net::ParsedCertificate::CreateFromCertificateCopy(der_cert.der_cert, |
| 125 {}); | 125 {}); |
| 126 if (!cert) | 126 if (!cert) |
| 127 PrintCertError("ERROR: ParsedCertificate failed:", der_cert); | 127 PrintCertError("ERROR: ParsedCertificate failed:", der_cert); |
| 128 else { | 128 else { |
| 129 trust_store.AddTrustAnchor( | 129 trust_store.AddTrustAnchor( |
| 130 net::TrustAnchor::CreateFromCertificateNoConstraints(cert)); | 130 net::TrustAnchor::CreateFromCertificateNoConstraints(cert)); |
| 131 } | 131 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 if (!DumpParsedCertificateChain( | 213 if (!DumpParsedCertificateChain( |
| 214 dump_prefix_path.AddExtension( | 214 dump_prefix_path.AddExtension( |
| 215 FILE_PATH_LITERAL(".CertPathBuilder.pem")), | 215 FILE_PATH_LITERAL(".CertPathBuilder.pem")), |
| 216 result.paths[result.best_result_index]->path)) { | 216 result.paths[result.best_result_index]->path)) { |
| 217 return false; | 217 return false; |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 return result.error() == net::OK; | 221 return result.error() == net::OK; |
| 222 } | 222 } |
| OLD | NEW |