Prusa Slicer 2.6.0
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< CurlGlobalInitinstance
 

Detailed Description

Constructor & Destructor Documentation

◆ CurlGlobalInit()

Slic3r::CurlGlobalInit::CurlGlobalInit ( )
inline
40 {
41#ifdef OPENSSL_CERT_OVERRIDE // defined if SLIC3R_STATIC=ON
42
43 // Look for a set of distro specific directories. Don't change the
44 // order: https://bugzilla.redhat.com/show_bug.cgi?id=1053882
45 static const char * CA_BUNDLES[] = {
46 "/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL 6
47 "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
48 "/usr/share/ssl/certs/ca-bundle.crt",
49 "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
50 "/etc/ssl/cert.pem",
51 "/etc/ssl/ca-bundle.pem" // OpenSUSE Tumbleweed
52 };
53
54 namespace fs = boost::filesystem;
55 // Env var name for the OpenSSL CA bundle (SSL_CERT_FILE nomally)
56 const char *const SSL_CA_FILE = X509_get_default_cert_file_env();
57 const char * ssl_cafile = ::getenv(SSL_CA_FILE);
58
59 if (!ssl_cafile)
60 ssl_cafile = X509_get_default_cert_file();
61
62 int replace = true;
63 if (!ssl_cafile || !fs::exists(fs::path(ssl_cafile))) {
64 const char * bundle = nullptr;
65 for (const char * b : CA_BUNDLES) {
66 if (fs::exists(fs::path(b))) {
67 ::setenv(SSL_CA_FILE, bundle = b, replace);
68 break;
69 }
70 }
71
72 if (!bundle)
73 message = _u8L("Could not detect system SSL certificate store. "
74 "PrusaSlicer will be unable to establish secure "
75 "network connections.");
76 else
78 _L("PrusaSlicer detected system SSL certificate store in: %1%"),
79 bundle);
80
82 _L("To specify the system certificate store manually, please "
83 "set the %1% environment variable to the correct CA bundle "
84 "and restart the application."),
85 SSL_CA_FILE);
86 }
87
88#endif // OPENSSL_CERT_OVERRIDE
89
90 if (CURLcode ec = ::curl_global_init(CURL_GLOBAL_DEFAULT)) {
91 message += _u8L("CURL init has failed. PrusaSlicer will be unable to establish "
92 "network connections. See logs for additional details.");
93
94 BOOST_LOG_TRIVIAL(error) << ::curl_easy_strerror(ec);
95 }
96 }
#define _u8L(s)
macro used to mark string used at localization, return same string
Definition SLAPrint.cpp:29
char * getenv()
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:56
Definition Utils.hpp:15
#define _L(s)
Definition I18N.hpp:3
std::string message
Definition Http.cpp:37
static char error[256]
Definition tga.cpp:50

References _L, _u8L, error, Slic3r::GUI::format(), getenv(), and message.

+ Here is the call graph for this function:

◆ ~CurlGlobalInit()

Slic3r::CurlGlobalInit::~CurlGlobalInit ( )
inline
98{ ::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: