Skip to content

Commit c8554ff

Browse files
committed
- Fix to link with -lcrypt32 for OpenSSL 3.2.0 on Windows.
1 parent 3d95cef commit c8554ff

File tree

4 files changed

+119
-52
lines changed

4 files changed

+119
-52
lines changed

acx_nlnetlabs.m4

+49-31
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
33
# BSD licensed.
44
#
5-
# Version 46
5+
# Version 47
6+
# 2024-01-15 fix to add crypt32 to -lcrypto link check when checking for gdi32.
67
# 2023-05-04 fix to remove unused whitespace.
78
# 2023-01-26 fix -Wstrict-prototypes.
89
# 2022-09-01 fix checking if nonblocking sockets work on OpenBSD.
@@ -707,7 +708,7 @@ AC_DEFUN([ACX_SSL_CHECKS], [
707708
LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir_lib"
708709
ACX_RUNTIME_PATH_ADD([$ssldir_lib])
709710
fi
710-
711+
711712
AC_MSG_CHECKING([for EVP_sha256 in -lcrypto])
712713
LIBS="$LIBS -lcrypto"
713714
LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto"
@@ -732,38 +733,55 @@ AC_DEFUN([ACX_SSL_CHECKS], [
732733
]])],[
733734
AC_DEFINE([HAVE_EVP_SHA256], 1,
734735
[If you have EVP_sha256])
735-
AC_MSG_RESULT(yes)
736+
AC_MSG_RESULT(yes)
736737
],[
737738
AC_MSG_RESULT(no)
738739
LIBS="$BAKLIBS"
739740
LIBSSL_LIBS="$BAKSSLLIBS"
740-
LIBS="$LIBS -ldl"
741-
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
742-
AC_MSG_CHECKING([if -lcrypto needs -ldl])
743-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
744-
int EVP_sha256(void);
745-
(void)EVP_sha256();
746-
]])],[
747-
AC_DEFINE([HAVE_EVP_SHA256], 1,
748-
[If you have EVP_sha256])
749-
AC_MSG_RESULT(yes)
750-
],[
751-
AC_MSG_RESULT(no)
752-
LIBS="$BAKLIBS"
753-
LIBSSL_LIBS="$BAKSSLLIBS"
754-
LIBS="$LIBS -ldl -pthread"
755-
LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
756-
AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread])
757-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
758-
int EVP_sha256(void);
759-
(void)EVP_sha256();
760-
]])],[
761-
AC_DEFINE([HAVE_EVP_SHA256], 1,
762-
[If you have EVP_sha256])
763-
AC_MSG_RESULT(yes)
764-
],[
765-
AC_MSG_RESULT(no)
766-
AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
741+
742+
LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32"
743+
LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32"
744+
AC_MSG_CHECKING([if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32])
745+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
746+
int EVP_sha256(void);
747+
(void)EVP_sha256();
748+
]])],[
749+
AC_DEFINE([HAVE_EVP_SHA256], 1,
750+
[If you have EVP_sha256])
751+
AC_MSG_RESULT(yes)
752+
],[
753+
AC_MSG_RESULT(no)
754+
LIBS="$BAKLIBS"
755+
LIBSSL_LIBS="$BAKSSLLIBS"
756+
757+
LIBS="$LIBS -ldl"
758+
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
759+
AC_MSG_CHECKING([if -lcrypto needs -ldl])
760+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
761+
int EVP_sha256(void);
762+
(void)EVP_sha256();
763+
]])],[
764+
AC_DEFINE([HAVE_EVP_SHA256], 1,
765+
[If you have EVP_sha256])
766+
AC_MSG_RESULT(yes)
767+
],[
768+
AC_MSG_RESULT(no)
769+
LIBS="$BAKLIBS"
770+
LIBSSL_LIBS="$BAKSSLLIBS"
771+
LIBS="$LIBS -ldl -pthread"
772+
LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
773+
AC_MSG_CHECKING([if -lcrypto needs -ldl -pthread])
774+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
775+
int EVP_sha256(void);
776+
(void)EVP_sha256();
777+
]])],[
778+
AC_DEFINE([HAVE_EVP_SHA256], 1,
779+
[If you have EVP_sha256])
780+
AC_MSG_RESULT(yes)
781+
],[
782+
AC_MSG_RESULT(no)
783+
AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
784+
])
767785
])
768786
])
769787
])
@@ -779,7 +797,7 @@ AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT])
779797

780798
dnl Check for SSL, where SSL is mandatory
781799
dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
782-
dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
800+
dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
783801
dnl Checks main header files of SSL.
784802
dnl
785803
AC_DEFUN([ACX_WITH_SSL],

configure

+62-20
Original file line numberDiff line numberDiff line change
@@ -18104,19 +18104,53 @@ else
1810418104
$as_echo "no" >&6; }
1810518105
LIBS="$BAKLIBS"
1810618106
LIBSSL_LIBS="$BAKSSLLIBS"
18107-
LIBS="$LIBS -ldl"
18108-
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
18109-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5
18107+
18108+
LIBS="$LIBS -lgdi32 -lws2_32 -lcrypt32"
18109+
LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32 -lws2_32 -lcrypt32"
18110+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32" >&5
18111+
$as_echo_n "checking if -lcrypto needs -lgdi32 -lws2_32 -lcrypt32... " >&6; }
18112+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
18113+
/* end confdefs.h. */
18114+
18115+
int
18116+
main ()
18117+
{
18118+
18119+
int EVP_sha256(void);
18120+
(void)EVP_sha256();
18121+
18122+
;
18123+
return 0;
18124+
}
18125+
_ACEOF
18126+
if ac_fn_c_try_link "$LINENO"; then :
18127+
18128+
18129+
$as_echo "#define HAVE_EVP_SHA256 1" >>confdefs.h
18130+
18131+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
18132+
$as_echo "yes" >&6; }
18133+
18134+
else
18135+
18136+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
18137+
$as_echo "no" >&6; }
18138+
LIBS="$BAKLIBS"
18139+
LIBSSL_LIBS="$BAKSSLLIBS"
18140+
18141+
LIBS="$LIBS -ldl"
18142+
LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
18143+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl" >&5
1811018144
$as_echo_n "checking if -lcrypto needs -ldl... " >&6; }
18111-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
18145+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1811218146
/* end confdefs.h. */
1811318147

1811418148
int
1811518149
main ()
1811618150
{
1811718151

18118-
int EVP_sha256(void);
18119-
(void)EVP_sha256();
18152+
int EVP_sha256(void);
18153+
(void)EVP_sha256();
1812018154

1812118155
;
1812218156
return 0;
@@ -18127,28 +18161,28 @@ if ac_fn_c_try_link "$LINENO"; then :
1812718161

1812818162
$as_echo "#define HAVE_EVP_SHA256 1" >>confdefs.h
1812918163

18130-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
18164+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1813118165
$as_echo "yes" >&6; }
1813218166

1813318167
else
1813418168

18135-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
18169+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1813618170
$as_echo "no" >&6; }
18137-
LIBS="$BAKLIBS"
18138-
LIBSSL_LIBS="$BAKSSLLIBS"
18139-
LIBS="$LIBS -ldl -pthread"
18140-
LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
18141-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl -pthread" >&5
18171+
LIBS="$BAKLIBS"
18172+
LIBSSL_LIBS="$BAKSSLLIBS"
18173+
LIBS="$LIBS -ldl -pthread"
18174+
LIBSSL_LIBS="$LIBSSL_LIBS -ldl -pthread"
18175+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -lcrypto needs -ldl -pthread" >&5
1814218176
$as_echo_n "checking if -lcrypto needs -ldl -pthread... " >&6; }
18143-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
18177+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1814418178
/* end confdefs.h. */
1814518179

1814618180
int
1814718181
main ()
1814818182
{
1814918183

18150-
int EVP_sha256(void);
18151-
(void)EVP_sha256();
18184+
int EVP_sha256(void);
18185+
(void)EVP_sha256();
1815218186

1815318187
;
1815418188
return 0;
@@ -18159,14 +18193,18 @@ if ac_fn_c_try_link "$LINENO"; then :
1815918193

1816018194
$as_echo "#define HAVE_EVP_SHA256 1" >>confdefs.h
1816118195

18162-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
18196+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
1816318197
$as_echo "yes" >&6; }
1816418198

1816518199
else
1816618200

18167-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
18201+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1816818202
$as_echo "no" >&6; }
18169-
as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5
18203+
as_fn_error $? "OpenSSL found in $ssldir, but version 0.9.7 or higher is required" "$LINENO" 5
18204+
18205+
fi
18206+
rm -f core conftest.err conftest.$ac_objext \
18207+
conftest$ac_exeext conftest.$ac_ext
1817018208

1817118209
fi
1817218210
rm -f core conftest.err conftest.$ac_objext \
@@ -20166,7 +20204,11 @@ else
2016620204
WINDRES="$ac_cv_prog_WINDRES"
2016720205
fi
2016820206

20169-
LIBS="$LIBS -liphlpapi -lcrypt32"
20207+
if echo "$LIBS" | grep crypt32 >/dev/null; then
20208+
LIBS="$LIBS -liphlpapi"
20209+
else
20210+
LIBS="$LIBS -liphlpapi -lcrypt32"
20211+
fi
2017020212
WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
2017120213

2017220214
WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"

configure.ac

+5-1
Original file line numberDiff line numberDiff line change
@@ -1569,7 +1569,11 @@ if test "$USE_WINSOCK" = 1; then
15691569
#include <windows.h>
15701570
])
15711571
AC_CHECK_TOOL(WINDRES, windres)
1572-
LIBS="$LIBS -liphlpapi -lcrypt32"
1572+
if echo "$LIBS" | grep crypt32 >/dev/null; then
1573+
LIBS="$LIBS -liphlpapi"
1574+
else
1575+
LIBS="$LIBS -liphlpapi -lcrypt32"
1576+
fi
15731577
WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
15741578
AC_SUBST(WINAPPS)
15751579
WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"

doc/Changelog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
15 January 2024: Wouter
2+
- Fix to link with -lcrypt32 for OpenSSL 3.2.0 on Windows.
3+
14
9 January 2024: Wouter
25
- Merge #988: Fix NLnetLabs#981: dump_cache truncates large records.
36

0 commit comments

Comments
 (0)