summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimmo Saan <simmo.saan@gmail.com>2019-12-10 23:00:13 +0200
committerSébastien Helleu <flashcode@flashtux.org>2019-12-13 21:18:22 +0100
commit139a7053e4371c4f4999e51cac8976a5446ce11c (patch)
treec0aff5d4e3fb6e9094101eeb178f78eb30d35e84 /src
parent9c227de6bfa4c316223969df613d268af54576eb (diff)
downloadweechat-139a7053e4371c4f4999e51cac8976a5446ce11c.zip
irc: fix compilation with GnuTLS < 3.1.0 (issue #115)
Due to this ssl_password will be partially unused with GnuTLS < 3.1.0. In that case an encrypted SSL client cert import will simply fail.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-server.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 828924fab..1d59d1060 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -4710,11 +4710,24 @@ irc_server_gnutls_callback (const void *pointer, void *data,
/* key */
gnutls_x509_privkey_init (&server->tls_cert_key);
+
+/*
+ * gnutls_x509_privkey_import2 has no "Since: ..." in GnuTLS manual but
+ * GnuTLS NEWS file lists it being added in 3.1.0:
+ * https://gitlab.com/gnutls/gnutls/blob/2b715b9564681acb3008a5574dcf25464de8b038/NEWS#L2552
+ */
+#if LIBGNUTLS_VERSION_NUMBER >= 0x030100 /* 3.1.0 */
ret = gnutls_x509_privkey_import2 (server->tls_cert_key,
&filedatum,
GNUTLS_X509_FMT_PEM,
ssl_password,
0);
+#else
+ ret = gnutls_x509_privkey_import (server->tls_cert_key,
+ &filedatum,
+ GNUTLS_X509_FMT_PEM);
+#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x0301000 */
+
if (ret < 0)
{
ret = gnutls_x509_privkey_import_pkcs8 (