21 DIR *dirp = opendir(directory.c_str());
22 if (!dirp)
return false;
26 const std::string filename(directory +
"/" + std::string(dirent->d_name));
30 if (!(S_ISREG(stat.st_mode) || S_ISLNK(stat.st_mode)))
continue;
47 const char *ca_path_env = getenv(
"X509_CERT_DIR");
48 if (ca_path_env && *ca_path_env)
51 ca_path_ =
"/etc/grid-security/certificates";
52 const char *ca_bundle_env = getenv(
"X509_CERT_BUNDLE");
53 if (ca_bundle_env && *ca_bundle_env)
59 CURLcode res1 = curl_easy_setopt(handle, CURLOPT_CAPATH,
ca_path_.c_str());
60 CURLcode res2 = CURLE_OK;
62 res2 = curl_easy_setopt(handle, CURLOPT_CAINFO,
ca_bundle_.c_str());
64 return (res1 == CURLE_OK) && (res2 == CURLE_OK);
69 std::vector<std::string> candidates;
71 candidates.push_back(
"/etc/ssl/certs");
72 candidates.push_back(
"/etc/pki/tls/certs");
73 candidates.push_back(
"/etc/ssl");
74 candidates.push_back(
"/etc/pki/tls");
75 candidates.push_back(
"/etc/pki/ca-trust/extracted/pem");
76 candidates.push_back(
"/etc/ssl");
78 for (
unsigned i = 0; i < candidates.size(); ++i) {
80 const std::string bundle_candidate = candidates[i] +
"/ca-bundle.crt";
bool HasCertificates(const std::string &directory)
bool SymlinkExists(const std::string &path)
bool FileExists(const std::string &path)
bool ApplySslCertificatePath(CURL *handle) const
bool HasSuffix(const std::string &str, const std::string &suffix, const bool ignore_case)
void UseSystemCertificatePath()