summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-hook.c4
-rw-r--r--src/core/wee-hook.h11
-rw-r--r--src/core/wee-network.c8
-rw-r--r--src/plugins/irc/irc-server.c18
4 files changed, 38 insertions, 3 deletions
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 0e42cb8c1..4414e3a09 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -1776,7 +1776,11 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
int pk_algos_len,
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ gnutls_retr2_st *answer)
+#else
gnutls_retr_st *answer)
+#endif
{
struct t_hook *ptr_hook;
int rc;
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index 7b092de17..d4c5f8ea7 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -213,7 +213,12 @@ typedef int (t_hook_callback_connect)(void *data, int status,
typedef int (gnutls_callback_t)(void *data, gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_len, gnutls_retr_st *answer,
+ int pk_algos_len,
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ gnutls_retr2_st *answer,
+#else
+ gnutls_retr_st *answer,
+#endif
int action);
#endif
@@ -450,8 +455,12 @@ extern int hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
int pk_algos_len,
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ gnutls_retr2_st *answer);
+#else
gnutls_retr_st *answer);
#endif
+#endif
extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
struct t_gui_buffer *buffer,
const char *tags, const char *message,
diff --git a/src/core/wee-network.c b/src/core/wee-network.c
index f611d771a..468f94c82 100644
--- a/src/core/wee-network.c
+++ b/src/core/wee-network.c
@@ -100,12 +100,20 @@ network_init ()
network_set_gnutls_ca_file ();
#if LIBGNUTLS_VERSION_NUMBER >= 0x02090a
+ /* for gnutls >= 2.9.10 */
gnutls_certificate_set_verify_function (gnutls_xcred,
&hook_connect_gnutls_verify_certificates);
#endif
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ /* for gnutls >= 2.11.0 */
+ gnutls_certificate_set_retrieve_function (gnutls_xcred,
+ &hook_connect_gnutls_set_certificates);
+#else
+ /* for gnutls < 2.11.0 */
gnutls_certificate_client_set_retrieve_function (gnutls_xcred,
&hook_connect_gnutls_set_certificates);
#endif
+#endif
#ifdef HAVE_GCRYPT
gcry_check_version (GCRYPT_VERSION);
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 19cf92937..85a45f9ad 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2948,11 +2948,20 @@ int
irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
const gnutls_datum_t *req_ca, int nreq,
const gnutls_pk_algorithm_t *pk_algos,
- int pk_algos_len, gnutls_retr_st *answer,
+ int pk_algos_len,
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ gnutls_retr2_st *answer,
+#else
+ gnutls_retr_st *answer,
+#endif
int action)
{
struct t_irc_server *server;
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ gnutls_retr2_st tls_struct;
+#else
gnutls_retr_st tls_struct;
+#endif
gnutls_x509_crt_t cert_temp;
const gnutls_datum_t *cert_list;
gnutls_datum_t filedatum;
@@ -3145,7 +3154,12 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
}
else
{
+
+#if LIBGNUTLS_VERSION_NUMBER >= 0x020b00
+ tls_struct.cert_type = GNUTLS_CRT_X509;
+#else
tls_struct.type = GNUTLS_CRT_X509;
+#endif
tls_struct.ncerts = 1;
tls_struct.deinit_all = 0;
tls_struct.cert.x509 = &server->tls_cert;
@@ -3170,7 +3184,7 @@ irc_server_gnutls_callback (void *data, gnutls_session_t tls_session,
gnutls_free (cinfo.data);
}
#endif
- memcpy (answer, &tls_struct, sizeof (gnutls_retr_st));
+ memcpy (answer, &tls_struct, sizeof (tls_struct));
free (cert_str);
}
}