talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 4d8314d853000b542f3f08d50ad64f6c29b14f95
parent 08fb18d5ad12055e7c31ad057ffc570d4a6768d6
Author: Jonathan Boeing <jonathan.n.boeing@gmail.com>
Date:   Wed, 21 Jul 2021 01:31:24 -0700

Set the CA certificate path at runtime for Windows

Curl, as shipped with the Windows build of Claws, doesn't have a default
path to a CA certificate bundle.  All users of Curl need to set the path
at runtime.

Diffstat:
Msrc/plugins/fancy/claws.def | 1+
Msrc/plugins/fancy/fancy_viewer.c | 3+++
Msrc/plugins/libravatar/claws.def | 1+
Msrc/plugins/libravatar/libravatar_image.c | 3+++
Msrc/plugins/litehtml_viewer/claws.def | 1+
Msrc/plugins/litehtml_viewer/http.cpp | 6++++++
Msrc/plugins/spam_report/claws.def | 1+
Msrc/plugins/spam_report/spam_report.c | 18++++++++++++------
Msrc/plugins/vcalendar/claws.def | 1+
Msrc/plugins/vcalendar/vcal_folder.c | 6++++++
10 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/plugins/fancy/claws.def b/src/plugins/fancy/claws.def @@ -9,6 +9,7 @@ claws_fopen claws_fdopen claws_fclose claws_safe_fclose +claws_ssl_get_cert_file combobox_get_active_data combobox_select_by_data combobox_text_new diff --git a/src/plugins/fancy/fancy_viewer.c b/src/plugins/fancy/fancy_viewer.c @@ -677,6 +677,9 @@ static void *download_file_curl (void *data) curl_easy_setopt(curl, CURLOPT_WRITEDATA, viewer); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/src/plugins/libravatar/claws.def b/src/plugins/libravatar/claws.def @@ -10,6 +10,7 @@ claws_fopen claws_fdopen claws_fclose claws_safe_fclose +claws_ssl_get_cert_file extract_address get_locale_dir check_plugin_version diff --git a/src/plugins/libravatar/libravatar_image.c b/src/plugins/libravatar/libravatar_image.c @@ -111,6 +111,9 @@ static GdkPixbuf *pixbuf_from_url(const gchar *url, const gchar *md5, const gcha } curl_easy_setopt(curl, CURLOPT_FILE, file); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L); /* fail on HTTP error */ +#ifdef G_OS_WIN32 + curl_easy_setopt(curl, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif debug_print("retrieving URL to file: %s -> %s\n", url, filename); res = curl_easy_perform(curl); if (res != CURLE_OK) { diff --git a/src/plugins/litehtml_viewer/claws.def b/src/plugins/litehtml_viewer/claws.def @@ -1,5 +1,6 @@ LIBRARY CLAWS-MAIL.EXE EXPORTS +claws_ssl_get_cert_file debug_print_real debug_srcname get_rc_dir diff --git a/src/plugins/litehtml_viewer/http.cpp b/src/plugins/litehtml_viewer/http.cpp @@ -22,7 +22,10 @@ #include <string.h> #include "http.h" +extern "C" { +#include "ssl.h" #include "utils.h" +} struct Data { GInputStream *memory; @@ -51,6 +54,9 @@ http::http() curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L); curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif stream = NULL; } diff --git a/src/plugins/spam_report/claws.def b/src/plugins/spam_report/claws.def @@ -3,6 +3,7 @@ EXPORTS alertpanel base64_encode check_plugin_version +claws_ssl_get_cert_file compose_entry_append compose_forward compose_send diff --git a/src/plugins/spam_report/spam_report.c b/src/plugins/spam_report/spam_report.c @@ -240,6 +240,9 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar curl_easy_setopt(curl, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs); curl_easy_setopt(curl, CURLOPT_USERAGENT, SPAM_REPORT_USERAGENT "(" PLUGINS_URI ")"); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif res = curl_easy_perform(curl); if (res != CURLE_OK) debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res)); @@ -258,19 +261,22 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar } break; case INTF_HTTP_GET: - curl = curl_easy_init(); - curl_easy_setopt(curl, CURLOPT_URL, geturl); + curl = curl_easy_init(); + curl_easy_setopt(curl, CURLOPT_URL, geturl); curl_easy_setopt(curl, CURLOPT_USERAGENT, SPAM_REPORT_USERAGENT "(" PLUGINS_URI ")"); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writefunction_cb); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_writefunction_cb); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif res = curl_easy_perform(curl); if (res != CURLE_OK) debug_print("curl_easy_perfom failed: %s", curl_easy_strerror(res)); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response); - curl_easy_cleanup(curl); + curl_easy_cleanup(curl); spamreport_http_response_log(geturl, response); - /* On success the page should return "OK: nominated <msgid>" */ + /* On success the page should return "OK: nominated <msgid>" */ if (chunk.size < 13 || strstr(chunk.data, "OK: nominated") == NULL) { if (chunk.size > 0) { log_error(LOG_PROTOCOL, "%s: response was %s\n", geturl, chunk.data); diff --git a/src/plugins/vcalendar/claws.def b/src/plugins/vcalendar/claws.def @@ -21,6 +21,7 @@ claws_fopen claws_fdopen claws_fclose claws_safe_fclose +claws_ssl_get_cert_file cm_menu_create_action_group_full cm_menu_set_sensitive_full cm_toggle_menu_set_active_full diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c @@ -1595,6 +1595,9 @@ void *url_read_thread(void *data) curl_easy_setopt(curl_ctx, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(curl_ctx, CURLOPT_TIMEOUT, prefs_common_get_prefs()->io_timeout_secs); curl_easy_setopt(curl_ctx, CURLOPT_NOSIGNAL, 1); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl_ctx, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif #if LIBCURL_VERSION_NUM >= 0x070a00 if(vcalprefs.ssl_verify_peer == FALSE) { curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0); @@ -1718,6 +1721,9 @@ gboolean vcal_curl_put(gchar *url, FILE *fp, gint filesize, const gchar *user, c curl_easy_setopt(curl_ctx, CURLOPT_READFUNCTION, NULL); curl_easy_setopt(curl_ctx, CURLOPT_READDATA, fp); curl_easy_setopt(curl_ctx, CURLOPT_HTTPHEADER, headers); +#ifdef G_OS_WIN32 + curl_easy_setopt(curl_ctx, CURLOPT_CAINFO, claws_ssl_get_cert_file()); +#endif #if LIBCURL_VERSION_NUM >= 0x070a00 if(vcalprefs.ssl_verify_peer == FALSE) { curl_easy_setopt(curl_ctx, CURLOPT_SSL_VERIFYPEER, 0);