diff --git a/autoconf/m4/unreal.m4 b/autoconf/m4/unreal.m4 index 0d60a94c7..345fdf7c0 100644 --- a/autoconf/m4/unreal.m4 +++ b/autoconf/m4/unreal.m4 @@ -292,3 +292,23 @@ else AC_MSG_RESULT([no]) fi ]) + +AC_DEFUN([CHECK_X509_get0_notAfter], +[ +AC_MSG_CHECKING([for X509_get0_notAfter in SSL library]) +AC_LANG_PUSH(C) +SAVE_LIBS="$LIBS" +LIBS="$LIBS $CRYPTOLIB" +AC_TRY_LINK([#include ], + [X509_get0_notAfter(NULL);], + has_function=1, + has_function=0) +LIBS="$SAVE_LIBS" +AC_LANG_POP(C) +if test $has_function = 1; then + AC_MSG_RESULT([yes]) + AC_DEFINE([HAS_X509_get0_notAfter], [], [Define if ssl library has X509_get0_notAfter]) +else + AC_MSG_RESULT([no]) +fi +]) diff --git a/configure b/configure index 33a5708c2..77667a326 100755 --- a/configure +++ b/configure @@ -6575,6 +6575,53 @@ else $as_echo "no" >&6; } fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for X509_get0_notAfter in SSL library" >&5 +$as_echo_n "checking for X509_get0_notAfter in SSL library... " >&6; } +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +SAVE_LIBS="$LIBS" +LIBS="$LIBS $CRYPTOLIB" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +X509_get0_notAfter(NULL); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + has_function=1 +else + has_function=0 +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS="$SAVE_LIBS" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +if test $has_function = 1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAS_X509_get0_notAfter /**/" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + # Check whether --enable-dynamic-linking was given. if test "${enable_dynamic_linking+set}" = set; then : enableval=$enable_dynamic_linking; enable_dynamic_linking=$enableval diff --git a/configure.ac b/configure.ac index cccdb69c1..089bcff52 100644 --- a/configure.ac +++ b/configure.ac @@ -505,6 +505,7 @@ CHECK_SSL_CTX_SET1_CURVES_LIST CHECK_SSL_CTX_SET_MIN_PROTO_VERSION CHECK_SSL_CTX_SET_SECURITY_LEVEL CHECK_ASN1_TIME_diff +CHECK_X509_get0_notAfter AC_ARG_ENABLE(dynamic-linking, [AS_HELP_STRING([--disable-dynamic-linking], [Make the IRCd statically link with shared objects rather than dynamically (noone knows if disabling dynamic linking actually does anything or not)])], [enable_dynamic_linking=$enableval], [enable_dynamic_linking="yes"]) AS_IF([test $enable_dynamic_linking = "yes"], diff --git a/include/setup.h.in b/include/setup.h.in index 5a6be6100..f0f20bf9c 100644 --- a/include/setup.h.in +++ b/include/setup.h.in @@ -40,6 +40,9 @@ /* Define if ssl library has SSL_CTX_set_security_level */ #undef HAS_SSL_CTX_SET_SECURITY_LEVEL +/* Define if ssl library has X509_get0_notAfter */ +#undef HAS_X509_get0_notAfter + /* Define if you have crypt */ #undef HAVE_CRYPT diff --git a/src/tls.c b/src/tls.c index ae48f09ae..961e1a2fc 100644 --- a/src/tls.c +++ b/src/tls.c @@ -1339,7 +1339,7 @@ char *outdated_tls_client_build_string(char *pattern, Client *client) int check_certificate_expiry_ctx(SSL_CTX *ctx, char **errstr) { -#if !defined(HAS_ASN1_TIME_diff) +#if !defined(HAS_ASN1_TIME_diff) || !defined(HAS_X509_get0_notAfter) return 0; #else static char errbuf[512];