Added path_to_plain_ascii for use by driver-ssl

This commit is contained in:
2023-01-23 16:24:40 -05:00
parent fb48329090
commit 470d8a3c78
3 changed files with 37 additions and 8 deletions

View File

@@ -5,6 +5,7 @@
#include <filesystem>
extern std::string strerror_str(int err);
extern std::string path_to_plain_ascii(const std::filesystem::path &path);
namespace drvssl {
@@ -163,13 +164,17 @@ void ctx_load_cert_from_directory(SSL_CTX *ctx, const std::string &dir) {
std::vector<std::string> cert_paths;
for (const auto & entry : std::filesystem::directory_iterator(dir)) {
std::string fn = entry.path();
if (count_certificates(fn.c_str()) >= 1) {
cert_paths.push_back(fn);
}
if (contains_privatekey(fn.c_str())) {
key_paths.push_back(fn);
}
std::string fn = path_to_plain_ascii(entry.path());
if (fn.empty()) {
std::cerr << "Ignoring file with non-ascii filename: " << entry.path() << std::endl;
} else {
if (count_certificates(fn.c_str()) >= 1) {
cert_paths.push_back(fn);
}
if (contains_privatekey(fn.c_str())) {
key_paths.push_back(fn);
}
}
}
if (cert_paths.size() > 1) {