summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-04-17 16:07:14 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-11 21:05:42 +0200
commite5d18e1221b7f232822f0110d80f042ab3bb708e (patch)
tree26cde6ae03333017c73eaf092684c71cd798f5e1 /src
parent9e7d052517ea4c349a05e1dfcf9915781089af59 (diff)
downloadweechat-e5d18e1221b7f232822f0110d80f042ab3bb708e.zip
core: evaluate option weechat.network.gnutls_ca_file (issue #1285)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c5
-rw-r--r--src/core/wee-network.c41
2 files changed, 22 insertions, 24 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index d352d08bc..aa7fd4d0d 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -4497,8 +4497,9 @@ config_weechat_init_options ()
config_network_gnutls_ca_file = config_file_new_option (
weechat_config_file, ptr_section,
"gnutls_ca_file", "string",
- N_("file containing the certificate authorities (\"%h\" will be "
- "replaced by WeeChat home, \"~/.weechat\" by default)"),
+ N_("file containing the certificate authorities "
+ "(path is evaluated, see function string_eval_path_home in "
+ "plugin API reference)"),
NULL, 0, 0, CA_FILE, NULL, 0,
NULL, NULL, NULL,
&config_change_network_gnutls_ca_file, NULL, NULL,
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index 056a0c2f6..7f7dc4d14 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -92,40 +92,37 @@ network_init_gcrypt ()
void
network_set_gnutls_ca_file ()
{
- char *ca_path, *ca_path2;
+ char *ca_path;
if (weechat_no_gnutls)
return;
- ca_path = string_expand_home (CONFIG_STRING(config_network_gnutls_ca_file));
+ ca_path = string_eval_path_home (
+ CONFIG_STRING(config_network_gnutls_ca_file),
+ NULL, NULL, NULL);
if (ca_path)
{
- ca_path2 = string_replace (ca_path, "%h", weechat_home);
- if (ca_path2)
+ if (access (ca_path, R_OK) == 0)
{
- if (access (ca_path2, R_OK) == 0)
- {
- if (gnutls_certificate_set_x509_trust_file (gnutls_xcred, ca_path2,
- GNUTLS_X509_FMT_PEM) < 0)
- {
- gui_chat_printf (
- NULL,
- _("%sWarning: failed to load certificate authorities "
- "from file %s"),
- gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- ca_path2);
- }
- }
- else
+ if (gnutls_certificate_set_x509_trust_file (gnutls_xcred, ca_path,
+ GNUTLS_X509_FMT_PEM) < 0)
{
gui_chat_printf (
NULL,
- _("%sWarning: no certificate authorities loaded "
- "(file not found: %s)"),
+ _("%sWarning: failed to load certificate authorities "
+ "from file %s"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
- ca_path2);
+ ca_path);
}
- free (ca_path2);
+ }
+ else
+ {
+ gui_chat_printf (
+ NULL,
+ _("%sWarning: no certificate authorities loaded "
+ "(file not found: %s)"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
+ ca_path);
}
free (ca_path);
}