Skip to content

Commit

Permalink
Fix some old code
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAssassin committed May 5, 2024
1 parent b8883c9 commit 9be566f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/appimagetool_fetch_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class GetRequest {
}

void setUpTlsCaChainCompatibility(bool verbose) {
bool found = false;
bool foundFile = false;
bool foundDir = false;

// from curl 7.84.0 on, one can query the default values and check if these files or directories exist
// if not, we anyway run the detection
Expand All @@ -146,7 +147,7 @@ class GetRequest {
if (verbose) {
std::cerr << "libcurl's default CA certificate bundle file " << caInfo << " was found on this system" << std::endl;
}
found = true;
foundFile = true;
} else {
if (verbose) {
std::cerr << "libcurl's default CA certificate bundle file " << caInfo << " was not found on this system, nulling" << std::endl;
Expand All @@ -162,7 +163,7 @@ class GetRequest {
std::cerr << "libcurl's default CA certificate bundle directory " << caPath
<< " was found on this system" << std::endl;
}
found = true;
foundDir = true;
} else {
if (verbose) {
std::cerr << "libcurl's default CA certificate bundle directory " << caPath << " was not found on this system, nulling" << std::endl;
Expand All @@ -174,29 +175,29 @@ class GetRequest {
#warning "libcurl version too old, not trying to use default values for system-provided CA certificate bundles"
#endif

{
if (!foundFile) {
const auto chainFile = findCaBundleFile();
if (!chainFile.empty()) {
if (verbose) {
std::cerr << "Using CA bundle file in " << chainFile << std::endl;
}
setOption(CURLOPT_CAINFO, chainFile.c_str());
}
found = true;
foundFile = true;
}

{
if (!foundDir) {
const auto chainDir = findCaBundleDirectory();
if (!chainDir.empty()) {
if (verbose) {
std::cerr << "Using CA bundle file in " << chainDir << std::endl;
std::cerr << "Using CA bundle dir in " << chainDir << std::endl;
}
setOption(CURLOPT_CAINFO, chainDir.c_str());
setOption(CURLOPT_CAPATH, chainDir.c_str());
}
found = true;
foundDir = true;
}

if (!found) {
if (!foundFile && !foundDir) {
std::cerr << "Warning: could not find valid CA chain bundle, HTTPS requests will likely fail" << std::endl;
}
}
Expand Down

0 comments on commit 9be566f

Please sign in to comment.