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

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

Issue 2305083002: Misc changes to cert_verify_tool for errors (Closed)
Patch Set: correct comment Created 4 years, 3 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/cert_verify_tool_util.h" 5 #include "net/tools/cert_verify_tool/cert_verify_tool_util.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 std::string file_data; 53 std::string file_data;
54 if (!base::ReadFileToString(file_path, &file_data)) { 54 if (!base::ReadFileToString(file_path, &file_data)) {
55 std::cerr << "ERROR: ReadFileToString " << file_path.value() << ": " 55 std::cerr << "ERROR: ReadFileToString " << file_path.value() << ": "
56 << strerror(errno) << "\n"; 56 << strerror(errno) << "\n";
57 return false; 57 return false;
58 } 58 }
59 ExtractCertificatesFromData(file_data, file_path, certs); 59 ExtractCertificatesFromData(file_data, file_path, certs);
60 return true; 60 return true;
61 } 61 }
62 62
63 void ReadChainFromFile(const base::FilePath& file_path, 63 bool ReadChainFromFile(const base::FilePath& file_path,
64 CertInput* target, 64 CertInput* target,
65 std::vector<CertInput>* intermediates) { 65 std::vector<CertInput>* intermediates) {
66 std::vector<CertInput> tmp_certs; 66 std::vector<CertInput> tmp_certs;
67 if (!ReadCertificatesFromFile(file_path, &tmp_certs)) 67 if (!ReadCertificatesFromFile(file_path, &tmp_certs))
68 return; 68 return false;
69
70 if (tmp_certs.empty())
71 return true;
69 72
70 *target = tmp_certs.front(); 73 *target = tmp_certs.front();
71 74
72 intermediates->insert(intermediates->end(), ++tmp_certs.begin(), 75 intermediates->insert(intermediates->end(), ++tmp_certs.begin(),
73 tmp_certs.end()); 76 tmp_certs.end());
77 return true;
74 } 78 }
75 79
76 bool WriteToFile(const base::FilePath& file_path, const std::string& data) { 80 bool WriteToFile(const base::FilePath& file_path, const std::string& data) {
77 if (base::WriteFile(file_path, data.data(), data.size()) < 0) { 81 if (base::WriteFile(file_path, data.data(), data.size()) < 0) {
78 std::cerr << "ERROR: WriteFile " << file_path.value() << ": " 82 std::cerr << "ERROR: WriteFile " << file_path.value() << ": "
79 << strerror(errno) << "\n"; 83 << strerror(errno) << "\n";
80 return false; 84 return false;
81 } 85 }
82 return true; 86 return true;
83 } 87 }
84 88
85 void PrintCertError(const std::string& error, const CertInput& cert) { 89 void PrintCertError(const std::string& error, const CertInput& cert) {
86 std::cerr << error << " " << cert.source_file_path.value(); 90 std::cerr << error << " " << cert.source_file_path.value();
87 if (!cert.source_details.empty()) 91 if (!cert.source_details.empty())
88 std::cerr << " (" << cert.source_details << ")"; 92 std::cerr << " (" << cert.source_details << ")";
89 std::cerr << "\n"; 93 std::cerr << "\n";
90 } 94 }
OLDNEW
« no previous file with comments | « net/tools/cert_verify_tool/cert_verify_tool_util.h ('k') | net/tools/cert_verify_tool/verify_using_path_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698