Fix compiling with autotools and openssl 1.1.0
authorSebastian Blunt <sebastian@c4k3.net>
Sat, 29 Apr 2017 09:58:24 +0000 (11:58 +0200)
committerSebastian Blunt <sebastian@c4k3.net>
Sat, 29 Apr 2017 09:58:24 +0000 (11:58 +0200)
Since the functions previously checked against have been removed in
openssl 1.1.0, it would not compile. This changes it so that functions
available in both 1.0.2 and 1.1.0 are used instead.

I originally had a lot of problems getting it to work, using the example
from https://wiki.openssl.org/index.php/Library_Initialization#Autoconf
as then it would no longer link against ssl. It turns out that this was
because when AC_CHECK_LIB has a action-if-found specified, it will NOT
add ssl to LIBS, as opposed to what is said on
https://autotools.io/autoconf/finding.html -- I discovered this after
finally just going to the original documentation, which correctly
documents the macro
(https://www.gnu.org/software/autoconf/manual/autoconf-2.61/html_node/Libraries.html)

configure.ac

index 67716422b78bf84cee22c099c35ecd14b997c319..7664aa4379f3f4f36e1f48eba6d9772b927580b4 100644 (file)
@@ -113,8 +113,8 @@ AS_IF([test "x$with_ssl" = xmbedtls], [
 ])
 AS_IF([test "x$with_ssl" = xopenssl], [
        AC_CHECK_HEADERS([openssl/ssl.h], [], [AC_MSG_ERROR([could not find openssl/ssl.h])])
-       AC_CHECK_LIB([crypto], [BN_init], [], [AC_MSG_ERROR([could not find libcrypto])])
-       AC_CHECK_LIB([ssl], [SSL_library_init], [], [AC_MSG_ERROR([could not find libssl])])
+       AC_CHECK_LIB([crypto], [CRYPTO_new_ex_data], [], [AC_MSG_ERROR([could not find libcrypto])])
+       AC_CHECK_LIB([ssl], [SSL_new], [], [AC_MSG_ERROR([could not find libssl])])
 ])
 AS_IF([test "x$with_ssl" = xgnutls], [
        AC_CHECK_HEADERS([gnutls/gnutls.h], [], [AC_MSG_ERROR([could not find gnutls/gnutls.h])])