From e34de998fe02ea46c4a95ba4fb9608659d073f9f Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Fri, 22 Nov 2024 20:37:45 +0000 Subject: [PATCH] * src/ne_openssl.c: Fix OpenSSL 1.1.0 version checks. --- src/ne_openssl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ne_openssl.c b/src/ne_openssl.c index fd8a11d6..e0a268e2 100644 --- a/src/ne_openssl.c +++ b/src/ne_openssl.c @@ -37,7 +37,11 @@ #include #include -#if defined(NE_HAVE_TS_SSL) && OPENSSL_VERSION_NUMBER < 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#define HAVE_OPENSSL110 +#endif + +#if defined(NE_HAVE_TS_SSL) && !defined(HAVE_OPENSSL110) /* From OpenSSL 1.1.0 locking callbacks are no longer needed. */ #define WITH_OPENSSL_LOCKING (1) #include /* for abort() */ @@ -68,7 +72,7 @@ typedef unsigned char ne_d2i_uchar; typedef const unsigned char ne_d2i_uchar; #endif -#if OPENSSL_VERSION_NUMBER < 0x10100000L +#ifndef HAVE_OPENSSL110 #define X509_get0_notBefore X509_get_notBefore #define X509_get0_notAfter X509_get_notAfter #define X509_up_ref(x) x->references++ @@ -618,6 +622,7 @@ int ne_ssl_context_set_verify(ne_ssl_context *ctx, return 0; } +#ifdef HAVE_OPENSSL110 /* Map neon version constants to native OpenSSL constants, returns -1 * on versions not supported. */ static int proto_to_native(enum ne_ssl_protocol proto) @@ -637,13 +642,12 @@ static int proto_to_native(enum ne_ssl_protocol proto) return -1; } } +#endif int ne_ssl_context_set_versions(ne_ssl_context *ctx, enum ne_ssl_protocol min, enum ne_ssl_protocol max) { -#if OPENSSL_VERSION_NUMBER < 0x1010000L - return NE_SOCK_ERROR; -#else +#ifdef HAVE_OPENSSL110 int omin = proto_to_native(min), omax = proto_to_native(max), ret; if (omin < 0 || omax < 0) { @@ -656,6 +660,8 @@ int ne_ssl_context_set_versions(ne_ssl_context *ctx, enum ne_ssl_protocol min, ERR_clear_error(); return ret == 1 ? 0 : NE_SOCK_ERROR; +#else + return NE_SOCK_ERROR; #endif }