From fca498570e6e0091802e267bdeb5c7cecd6d53c7 Mon Sep 17 00:00:00 2001 From: JuanJakobo Date: Fri, 2 Sep 2022 09:46:17 +0200 Subject: [PATCH] #26 Enable option to use custom certs --- src/api/webDAV.cpp | 7 +++++++ src/api/webDAV.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/api/webDAV.cpp b/src/api/webDAV.cpp index 3c82774..de92574 100644 --- a/src/api/webDAV.cpp +++ b/src/api/webDAV.cpp @@ -231,6 +231,11 @@ string WebDAV::propfind(const string &pathUrl) curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PROPFIND"); 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()); + + //TODO add sorter here curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?> \ \ \ @@ -310,6 +315,8 @@ bool WebDAV::get(WebDAVItem &item) curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, Util::progress_callback); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + if (iv_access(CACERT_PATH.c_str(), R_OK) == 0) + curl_easy_setopt(curl, CURLOPT_CAINFO, CACERT_PATH.c_str()); res = curl_easy_perform(curl); curl_easy_cleanup(curl); iv_fclose(fp); diff --git a/src/api/webDAV.h b/src/api/webDAV.h index 76b62e2..eab38c6 100644 --- a/src/api/webDAV.h +++ b/src/api/webDAV.h @@ -17,8 +17,8 @@ const std::string NEXTCLOUD_ROOT_PATH = "/remote.php/dav/files/"; const std::string NEXTCLOUD_START_PATH = "/remote.php/"; -const std::string CACERT_PATH = "/mnt/ext1/applications/cacert.pem"; const std::string NEXTCLOUD_PATH = "/mnt/ext1/system/config/nextcloud"; +const std::string CACERT_PATH = NEXTCLOUD_PATH + "/customCert.pem"; class WebDAV {