1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 06:46:38 +02:00

core: evaluate option weechat.network.gnutls_ca_file (issue #1285)

This commit is contained in:
Sébastien Helleu
2021-04-17 16:07:14 +02:00
parent 9e7d052517
commit e5d18e1221
2 changed files with 22 additions and 24 deletions
+3 -2
View File
@@ -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,
+19 -22
View File
@@ -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);
}