| 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_cert_verify_proc.h" | 5 #include "net/tools/cert_verify_tool/verify_using_cert_verify_proc.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 std::string SubjectFromX509Certificate(const net::X509Certificate* cert) { | 55 std::string SubjectFromX509Certificate(const net::X509Certificate* cert) { |
| 56 return cert->subject().GetDisplayName(); | 56 return cert->subject().GetDisplayName(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Returns a textual representation of the Subject of |cert_handle|. | 59 // Returns a textual representation of the Subject of |cert_handle|. |
| 60 std::string SubjectFromOSCertHandle( | 60 std::string SubjectFromOSCertHandle( |
| 61 net::X509Certificate::OSCertHandle cert_handle) { | 61 net::X509Certificate::OSCertHandle cert_handle) { |
| 62 scoped_refptr<net::X509Certificate> cert = | 62 scoped_refptr<net::X509Certificate> cert = |
| 63 net::X509Certificate::CreateFromHandle( | 63 net::X509Certificate::CreateFromHandle( |
| 64 cert_handle, net::X509Certificate::OSCertHandles()); | 64 cert_handle, net::X509Certificate::OSCertHandles()); |
| 65 if (!cert) |
| 66 return std::string(); |
| 65 return SubjectFromX509Certificate(cert.get()); | 67 return SubjectFromX509Certificate(cert.get()); |
| 66 } | 68 } |
| 67 | 69 |
| 68 void PrintCertStatus(int cert_status) { | 70 void PrintCertStatus(int cert_status) { |
| 69 std::cout << base::StringPrintf("CertStatus: 0x%x\n", cert_status); | 71 std::cout << base::StringPrintf("CertStatus: 0x%x\n", cert_status); |
| 70 | 72 |
| 71 for (const auto& flag : kCertStatusFlags) { | 73 for (const auto& flag : kCertStatusFlags) { |
| 72 if ((cert_status & flag.constant) == flag.constant) | 74 if ((cert_status & flag.constant) == flag.constant) |
| 73 std::cout << " " << flag.name << "\n"; | 75 std::cout << " " << flag.name << "\n"; |
| 74 } | 76 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 if (!dump_prefix_path.empty() && result.verified_cert) { | 171 if (!dump_prefix_path.empty() && result.verified_cert) { |
| 170 if (!DumpX509CertificateChain(dump_prefix_path.AddExtension( | 172 if (!DumpX509CertificateChain(dump_prefix_path.AddExtension( |
| 171 FILE_PATH_LITERAL(".CertVerifyProc.pem")), | 173 FILE_PATH_LITERAL(".CertVerifyProc.pem")), |
| 172 result.verified_cert.get())) { | 174 result.verified_cert.get())) { |
| 173 return false; | 175 return false; |
| 174 } | 176 } |
| 175 } | 177 } |
| 176 | 178 |
| 177 return rv == net::OK; | 179 return rv == net::OK; |
| 178 } | 180 } |
| OLD | NEW |