OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::CurlGlobalInit Struct Reference
Collaboration diagram for Slic3r::CurlGlobalInit:

Public Member Functions

 CurlGlobalInit ()
 ~CurlGlobalInit ()

Public Attributes

std::string message

Static Public Attributes

static std::unique_ptr< CurlGlobalInit > instance

Detailed Description

Constructor & Destructor Documentation

◆ CurlGlobalInit()

Slic3r::CurlGlobalInit::CurlGlobalInit ( )
inline
50 {
51#ifdef OPENSSL_CERT_OVERRIDE // defined if SLIC3R_STATIC=ON
52
53 // Look for a set of distro specific directories. Don't change the
54 // order: https://bugzilla.redhat.com/show_bug.cgi?id=1053882
55 static const char * CA_BUNDLES[] = {
56 "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL 6
57 "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
58 "/usr/share/ssl/certs/ca-bundle.crt",
59 "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
60 "/etc/ssl/cert.pem",
61 "/etc/ssl/ca-bundle.pem" // OpenSUSE Tumbleweed
62 };
63
64 // Env var name for the OpenSSL CA bundle (SSL_CERT_FILE nomally)
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 // ORCA: non-throwing overload; fs_ec is deliberately unread. An existing but unreadable
73 // path (a static build's baked-in OPENSSLDIR run as another user, say) must fall
74 // through to CA_BUNDLES, not throw out of this constructor.
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 // OPENSSL_CERT_OVERRIDE
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

References message.

◆ ~CurlGlobalInit()

Slic3r::CurlGlobalInit::~CurlGlobalInit ( )
inline
101{ ::curl_global_cleanup(); }

Member Data Documentation

◆ instance

std::unique_ptr< CurlGlobalInit > Slic3r::CurlGlobalInit::instance
static

◆ message

std::string Slic3r::CurlGlobalInit::message

Referenced by CurlGlobalInit().


The documentation for this struct was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/Http.cpp