summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-03-06 22:29:03 +0100
committerSebastien Helleu <flashcode@flashtux.org>2011-03-06 22:29:03 +0100
commitb0a549210215cf7941b4ad739489ede6e0f9bd2c (patch)
tree1e6cef202f8aea91131992c3187283ec1da7ebd6 /src
parente70bbe0659c554566d26c803f27a8704979d04d3 (diff)
downloadweechat-b0a549210215cf7941b4ad739489ede6e0f9bd2c.zip
Reload file with certificate authorities when option weechat.network.gnutls_ca_file is changed
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c21
-rw-r--r--src/core/wee-network.c22
-rw-r--r--src/core/wee-network.h3
3 files changed, 40 insertions, 6 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index b81fa8357..a398443a0 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -41,6 +41,7 @@
#include "wee-config.h"
#include "wee-hook.h"
#include "wee-log.h"
+#include "wee-network.h"
#include "wee-util.h"
#include "wee-list.h"
#include "wee-proxy.h"
@@ -422,6 +423,23 @@ config_change_nick_colors (void *data, struct t_config_option *option)
}
/*
+ * config_change_network_gnutls_ca_file: called when gnutls_ca_file is changed
+ */
+
+void
+config_change_network_gnutls_ca_file (void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) option;
+
+ if (network_init_ok)
+ network_set_gnutls_ca_file ();
+}
+
+
+/*
* config_day_change_timer_cb: timer callback for displaying
* "Day changed to xxx" message
*/
@@ -2191,7 +2209,8 @@ config_weechat_init_options ()
"gnutls_ca_file", "string",
N_("file containing the certificate authorities (\"%h\" will be "
"replaced by WeeChat home, \"~/.weechat\" by default)"),
- NULL, 0, 0, "%h/ssl/CAs.pem", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ NULL, 0, 0, "%h/ssl/CAs.pem", NULL, 0, NULL, NULL,
+ &config_change_network_gnutls_ca_file, NULL, NULL, NULL);
config_network_gnutls_handshake_timeout = config_file_new_option (
weechat_config_file, ptr_section,
"gnutls_handshake_timeout", "integer",
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index 0017cb914..c111ce40a 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -70,17 +70,14 @@ const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
/*
- * network_init: init network
+ * network_set_gnutls_ca_file: set trust file with option gnutls_ca_file
*/
void
-network_init ()
+network_set_gnutls_ca_file ()
{
#ifdef HAVE_GNUTLS
char *ca_path, *ca_path2;
-
- gnutls_global_init ();
- gnutls_certificate_allocate_credentials (&gnutls_xcred);
ca_path = string_expand_home (CONFIG_STRING(config_network_gnutls_ca_file));
if (ca_path)
@@ -94,6 +91,21 @@ network_init ()
}
free (ca_path);
}
+#endif
+}
+
+/*
+ * network_init: init network
+ */
+
+void
+network_init ()
+{
+#ifdef HAVE_GNUTLS
+ gnutls_global_init ();
+ gnutls_certificate_allocate_credentials (&gnutls_xcred);
+
+ network_set_gnutls_ca_file ();
#if LIBGNUTLS_VERSION_NUMBER >= 0x02090a
gnutls_certificate_set_verify_function (gnutls_xcred,
&hook_connect_gnutls_verify_certificates);
diff --git a/src/core/wee-network.h b/src/core/wee-network.h
index 33fd9fbc6..834f3ad38 100644
--- a/src/core/wee-network.h
+++ b/src/core/wee-network.h
@@ -40,6 +40,9 @@ struct t_network_socks5
/* auth(user/pass) (2), ... */
};
+extern int network_init_ok;
+
+extern void network_set_gnutls_ca_file ();
extern void network_init ();
extern void network_end ();
extern int network_pass_proxy (const char *proxy, int sock,