Skip to content

Commit

Permalink
GnuTLS: use gnutls_transport_set_int if available
Browse files Browse the repository at this point in the history
gnutls_transport_set_ptr may cause problems on some platforms,
therefore the replacement gnutls_transport_set_int is used
when available (since GnuTLS >= 3.1.9).
  • Loading branch information
joergsteffens authored and Marco van Wieringen committed Feb 17, 2015
1 parent 8cb191f commit 5104fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autoconf/configure.in
Expand Up @@ -1275,6 +1275,10 @@ if test "x$support_crypto" != "xno" -o "x$support_tls" != "xno"; then

if test "$have_gnutls" = "yes"; then
AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if GNUTLS library is available])
# gnutls_transport_set_ptr may cause problems on some platforms,
# therefore the replacement gnutls_transport_set_int is used
# when available (since GnuTLS >= 3.1.9)
AC_CHECK_FUNCS(gnutls_transport_set_int)
fi

if test "$support_tls" != "no" -a "$have_gnutls" = "yes"; then
Expand Down
7 changes: 7 additions & 0 deletions src/lib/tls_gnutls.c
Expand Up @@ -490,8 +490,15 @@ TLS_CONNECTION *new_tls_connection(TLS_CONTEXT *ctx, int fd, bool server)

/*
* Link the TLS session and the filedescriptor of the socket used.
* gnutls_transport_set_ptr may cause problems on some platforms,
* therefore the replacement gnutls_transport_set_int is used,
* when available (since GnuTLS >= 3.1.9)
*/
#ifdef HAVE_GNUTLS_TRANSPORT_SET_INT
gnutls_transport_set_int(tls->gnutls_state, fd);
#else
gnutls_transport_set_ptr(tls->gnutls_state, (gnutls_transport_ptr_t)fd);
#endif

/*
* Server specific settings.
Expand Down

0 comments on commit 5104fea

Please sign in to comment.