21 DIR *dirp = opendir(directory.c_str());
27 const std::string filename(directory +
"/" + std::string(dirent->d_name));
32 if (!(S_ISREG(stat.st_mode) || S_ISLNK(stat.st_mode)))
50 const char *ca_path_env = getenv(
"X509_CERT_DIR");
51 if (ca_path_env && *ca_path_env)
54 ca_path_ =
"/etc/grid-security/certificates";
55 const char *ca_bundle_env = getenv(
"X509_CERT_BUNDLE");
56 if (ca_bundle_env && *ca_bundle_env)
62 CURLcode res1 = curl_easy_setopt(handle, CURLOPT_CAPATH,
ca_path_.c_str());
63 CURLcode res2 = CURLE_OK;
65 res2 = curl_easy_setopt(handle, CURLOPT_CAINFO,
ca_bundle_.c_str());
67 return (res1 == CURLE_OK) && (res2 == CURLE_OK);
72 std::vector<std::string> candidates;
74 candidates.push_back(
"/etc/ssl/certs");
75 candidates.push_back(
"/etc/pki/tls/certs");
76 candidates.push_back(
"/etc/ssl");
77 candidates.push_back(
"/etc/pki/tls");
78 candidates.push_back(
"/etc/pki/ca-trust/extracted/pem");
79 candidates.push_back(
"/etc/ssl");
81 for (
unsigned i = 0; i < candidates.size(); ++i) {
83 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()