Skip to content

Commit

Permalink
fix iss regarding Expiration of Lets Encrypt cert
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanJakobo committed Oct 18, 2021
1 parent 38d3839 commit e48b8cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/util/nextcloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ void Nextcloud::downloadItem(vector<Item> &tempItems, int itemID)
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, Util::progress_callback);
//in case that cacert is available use it
if (iv_access(CACERT_PATH.c_str(), W_OK) == 0)
curl_easy_setopt(curl, CURLOPT_CAINFO, CACERT_PATH.c_str());
else
Log::writeLog("could not find cacert");
//Follow redirects
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
res = curl_easy_perform(curl);
Expand Down Expand Up @@ -220,7 +225,9 @@ void Nextcloud::downloadItem(vector<Item> &tempItems, int itemID)
}
else
{
string response = std::string("An error occured. (") + curl_easy_strerror(res) + " (Curl Error Code: " + std::to_string(res) + ")). Please try again.";
string response = std::string("An error occured. (") + curl_easy_strerror(res) + " (Curl Error Code: " + std::to_string(res) + ")). Please try again.";
if(res == 60)
response = "Seems as if you are using Let's Encrypt Certs. Please follow the guide on Github (https://github.com/JuanJakobo/Pocketbook-Nextcloud-Client) to use a custom Cert Store on PB.";
Message(ICON_ERROR, "Error", response.c_str(), 4000);
}
}
Expand Down Expand Up @@ -328,6 +335,11 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, Util::writeCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

if (iv_access(CACERT_PATH.c_str(), R_OK) == 0)
curl_easy_setopt(curl, CURLOPT_CAINFO, CACERT_PATH.c_str());
else
Log::writeLog("could not find cacert");

res = curl_easy_perform(curl);
curl_easy_cleanup(curl);

Expand Down Expand Up @@ -395,7 +407,9 @@ vector<Item> Nextcloud::getDataStructure(const string &pathUrl, const string &Us
}
else
{
string response = std::string("An error occured. (") + curl_easy_strerror(res) + " (Curl Error Code: " + std::to_string(res) + ")). Please try again.";
string response = std::string("An error occured. (") + curl_easy_strerror(res) + " (Curl Error Code: " + std::to_string(res) + ")). Please try again.";
if(res == 60)
response = "Seems as if you are using Let's Encrypt Certs. Please follow the guide on Github (https://github.com/JuanJakobo/Pocketbook-Nextcloud-Client) to use a custom Cert Store on PB.";
Message(ICON_ERROR, "Error", response.c_str(), 4000);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/util/nextcloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const std::string NEXTCLOUD_FILE_PATH = "/mnt/ext1/nextcloud";
const std::string NEXTCLOUD_ROOT_PATH = "/remote.php/dav/files/";
const std::string NEXTCLOUD_STRUCTURE_EXTENSION = ".structure";
const std::string NEXTCLOUD_START_PATH = "/remote.php/";
const std::string CACERT_PATH = "/mnt/ext1/applications/cacert.pem";

class Nextcloud
{
Expand Down

0 comments on commit e48b8cc

Please sign in to comment.