50 {
51#ifdef OPENSSL_CERT_OVERRIDE
52
53
54
55 static const char * CA_BUNDLES[] = {
56 "/etc/pki/tls/certs/ca-bundle.crt",
57 "/etc/ssl/certs/ca-certificates.crt",
58 "/usr/share/ssl/certs/ca-bundle.crt",
59 "/usr/local/share/certs/ca-root-nss.crt",
60 "/etc/ssl/cert.pem",
61 "/etc/ssl/ca-bundle.pem"
62 };
63
64
65 const char *const SSL_CA_FILE = X509_get_default_cert_file_env();
66 const char * ssl_cafile = ::getenv(SSL_CA_FILE);
67
68 if (!ssl_cafile)
69 ssl_cafile = X509_get_default_cert_file();
70
71 int replace = true;
72
73
74
75 boost::system::error_code fs_ec;
76 if (!ssl_cafile || !fs::exists(fs::path(ssl_cafile), fs_ec)) {
77 const char * bundle = nullptr;
78 for (const char * b : CA_BUNDLES) {
79 if (fs::exists(fs::path(b), fs_ec)) {
80 ::setenv(SSL_CA_FILE, bundle = b, replace);
81 break;
82 }
83 }
84
85 if (!bundle)
86 message =
"Unable to get system certificate.";
87 else
88 message = (boost::format(
"use system SSL certificate: %1%") % bundle).str();
89
90 message +=
"\n" + (boost::format(
"To manually specify the system certificate store, "
91 "set the %1% environment variable to the correct CA and restart the application") % SSL_CA_FILE).str();
92 }
93#endif
94
95 if (CURLcode ec = ::curl_global_init(CURL_GLOBAL_DEFAULT)) {
96 message +=
"CURL initialization failed. See the log for additional details.";
97 BOOST_LOG_TRIVIAL(error) << ::curl_easy_strerror(ec);
98 }
99 }
std::string message
Definition Http.cpp:47