size_t count = 0;
for (const auto& filename : ocspFiles) {
+ const size_t idx = count++;
std::ifstream file(filename, std::ios::binary);
std::string content;
while (file) {
- char buffer[4096];
- file.read(buffer, sizeof(buffer));
+ std::array<char, 4096> buffer{};
+ file.read(buffer.data(), buffer.size());
if (file.bad()) {
file.close();
warnings.push_back("Unable to load OCSP response from " + filename);
continue;
}
- content.append(buffer, file.gcount());
+ content.append(buffer.data(), file.gcount());
}
file.close();
try {
libssl_validate_ocsp_response(content);
- ocspResponses.insert({keyTypes.at(count), std::move(content)});
+ ocspResponses.insert({keyTypes.at(idx), std::move(content)});
}
catch (const std::exception& e) {
warnings.push_back("Error checking the validity of OCSP response from '" + filename + "': " + e.what());
continue;
}
- ++count;
}
return ocspResponses;