Skip to content

Commit

Permalink
Fix build with local installation of OpenSSL
Browse files Browse the repository at this point in the history
Compile and linker flags are not correctly set when building Cherokee webserver
using a local (additional) installation of OpenSSL (e. g. in /usr/local/openssl).

When users pass an OpenSSL path, with option, e. g., --with-libssl=/usr/local/openssl
Cherokee checks for existence of:
- libssl and libcrypto in /usr/local/openssl/lib
- openssl in /usr/local/openssl/bin
During further build process these paths are used to analyze, compile and link
Cherokee against the correct TLS back-end.

This patch also adds some further checks of OpenSSL header files.

Fixes: cherokee#1251

Signed-off-by: Thomas Reim <reimth@gmail.com>
  • Loading branch information
thor-sssd committed Apr 3, 2021
1 parent dd1d666 commit 687f5dc
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1085,17 +1085,35 @@ AC_ARG_WITH(libssl,
have_openssl=no

if test "$WITH_OPENSSL" != "no"; then
dnl backup the pre-ssl variables
CLEANLDFLAGS="$LDFLAGS"
CLEANCFLAGS="$CFLAGS"
CLEANLIBS="$LIBS"
if test "$WITH_OPENSSL" != "yes"; then
LIBSSL_CFLAGS="-I$WITH_OPENSSL/include"
LIBSSL_CFLAGS="-I$WITH_OPENSSL/include -I$WITH_OPENSSL/include/openssl"
LIBSSL_LIBS="-L$WITH_OPENSSL/lib"
LIBCRYPTO_LIBS="-L$WITH_OPENSSL/lib"
OPENSSL_PATH="$WITH_OPENSSL/bin"
fi

CFLAGS="$CFLAGS $LIBSSL_CFLAGS"
LDFLAGS="$LDFLAGS $LIBSSL_LIBS"

AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
have_openssl="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [have_openssl="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [have_openssl="yes"])
AC_CHECK_LIB(ssl, SSL_accept, [have_openssl=yes])

if test "$have_openssl" = "yes"; then
AC_CHECK_HEADERS(openssl/dh.h openssl/rand.h openssl/crypto.h \
openssl/lhash.h openssl/ssl.h openssl/err.h,
AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL/libssl library]),
have_openssl="no"
)
fi
AS_IF([test "x$have_openssl" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])

if test "$have_openssl" = "yes"; then
TLS_BACK_END="OpenSSL/libssl"
OPENSSL_PATH="$OPENSSL_PATH$PATH_SEPARATOR$PATH"
Expand All @@ -1104,7 +1122,6 @@ if test "$WITH_OPENSSL" != "no"; then
AC_SUBST(LIBSSL_LIBS)
AC_SUBST(LIBSSL_CFLAGS)

AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL library])
AC_CACHE_CHECK([for a suitable test server to verify $TLS_BACK_END TLS protocol support], [ac_cv_path_OPENSSL_BIN],
[AC_PATH_PROGS_FEATURE_CHECK([OPENSSL_BIN], [openssl],
[v=$($ac_path_OPENSSL_BIN s_server -help 2>&1)
Expand Down Expand Up @@ -1155,10 +1172,13 @@ if test "$WITH_OPENSSL" != "no"; then
if test "$have_openssl_ciphersuites" = "yes"; then
AC_DEFINE(HAVE_SSL_CTX_SET_CIPHERSUITES, 1, [OpenSSL/libssl has SSL_CTX_set_ciphersuites() function])
fi

AC_CHECK_HEADERS([openssl/engine.h])
fi
# restore CFLAGS and LDFLAGS
CFLAGS="${CLEANCFLAGS}"
LDFLAGS="${CLEANLDFLAGS}"
fi
AC_MSG_CHECKING(for libssl)
AC_MSG_RESULT([$have_openssl])

AM_CONDITIONAL(USE_OPENSSL, test "x$have_openssl" = "xyes")

Expand Down

0 comments on commit 687f5dc

Please sign in to comment.