aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorSteffen Jaeckel <jaeckel-floss@eyet-services.de>2022-03-22 11:26:53 +0100
committerSteffen Jaeckel <jaeckel-floss@eyet-services.de>2022-03-22 11:44:01 +0100
commit7f1f9787cb6de128d2ddc628dd57b9d89cba51ec (patch)
tree037397a08572305356ee06ab22f767ea9e7aeefb /src/tools
parentb28ac093688d0d3dbda8aa9755e1b9b54ed01e05 (diff)
downloadprofani-tty-7f1f9787cb6de128d2ddc628dd57b9d89cba51ec.tar.gz
add profanity-specific CAfile
The profanity-internal mechanism to allow connecting to a server isn't easily portable to cURL. Therefor introduce a profanity-specific CAfile which is managed individually and will be configured in libcurl calls. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/http_download.c6
-rw-r--r--src/tools/http_upload.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/tools/http_download.c b/src/tools/http_download.c
index d4df5f6b..cd2a7553 100644
--- a/src/tools/http_download.c
+++ b/src/tools/http_download.c
@@ -50,6 +50,7 @@
#include "profanity.h"
#include "event/client_events.h"
#include "tools/http_download.h"
+#include "config/cafile.h"
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/window.h"
@@ -125,6 +126,7 @@ http_file_get(void* userdata)
}
char* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
+ gchar* cafile = cafile_get_name();
pthread_mutex_unlock(&lock);
curl_global_init(CURL_GLOBAL_ALL);
@@ -145,6 +147,9 @@ http_file_get(void* userdata)
curl_easy_setopt(curl, CURLOPT_USERAGENT, "profanity");
+ if (cafile) {
+ curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
+ }
if (cert_path) {
curl_easy_setopt(curl, CURLOPT_CAPATH, cert_path);
}
@@ -161,6 +166,7 @@ http_file_get(void* userdata)
}
pthread_mutex_lock(&lock);
+ g_free(cafile);
g_free(cert_path);
if (err) {
if (download->cancel) {
diff --git a/src/tools/http_upload.c b/src/tools/http_upload.c
index d1360b46..ca336c9b 100644
--- a/src/tools/http_upload.c
+++ b/src/tools/http_upload.c
@@ -48,6 +48,7 @@
#include "profanity.h"
#include "event/client_events.h"
#include "tools/http_upload.h"
+#include "config/cafile.h"
#include "config/preferences.h"
#include "ui/ui.h"
#include "ui/window.h"
@@ -184,6 +185,7 @@ http_file_put(void* userdata)
g_free(msg);
char* cert_path = prefs_get_string(PREF_TLS_CERTPATH);
+ gchar* cafile = cafile_get_name();
pthread_mutex_unlock(&lock);
curl_global_init(CURL_GLOBAL_ALL);
@@ -244,6 +246,9 @@ http_file_put(void* userdata)
fh = upload->filehandle;
+ if (cafile) {
+ curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
+ }
if (cert_path) {
curl_easy_setopt(curl, CURLOPT_CAPATH, cert_path);
}
@@ -288,6 +293,7 @@ http_file_put(void* userdata)
g_free(expires_header);
pthread_mutex_lock(&lock);
+ g_free(cafile);
g_free(cert_path);
if (err) {