Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL_CERT_DIR #1913

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions core/utils/asio_ssl_context_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,27 @@ namespace kagome {
// X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT
// X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
[[maybe_unused]] static bool find_system_certificates = [] {
// SSL_CERT_FILE
if (getenv(X509_get_default_cert_file_env()) != nullptr) {
return true;
}
// SSL_CERT_DIR
if (getenv(X509_get_default_cert_dir_env()) != nullptr) {
return true;
}
constexpr auto extra = "/etc/ssl/cert.pem";
if (getenv(X509_get_default_cert_file_env()) == nullptr
and getenv(X509_get_default_cert_dir_env()) == nullptr
and std::string_view{X509_get_default_cert_file()} != extra
if (std::string_view{X509_get_default_cert_file()} != extra
and std::filesystem::exists(extra)) {
setenv(X509_get_default_cert_file_env(), extra, true);
return true;
}
constexpr auto extra_dir = "/etc/ssl/certs";
std::error_code ec;
if (std::string_view{X509_get_default_cert_dir()} != extra_dir
and std::filesystem::directory_iterator{extra_dir, ec}
!= std::filesystem::directory_iterator{}) {
setenv(X509_get_default_cert_dir_env(), extra_dir, true);
return true;
}
return true;
}();
Expand Down
Loading