Skip to content

Commit bd0dea4

Browse files
committed
Compile fixes for OpenSSL 4.0.0
This does two things: * We now only compile src/openssl_hostname_validation.c on really old OpenSSL's. This was already unused/dead code for most OpenSSL's but we always compiled it in until now. * Added 'const' to please OpenSSL 4.0.0 while not breaking OpenSSL 1.0.x. And yeah i'm happy to drop OpenSSL 1.0.x support real soon... but not this month yet.
1 parent a89f098 commit bd0dea4

5 files changed

Lines changed: 17 additions & 4 deletions

File tree

autoconf/m4/unreal.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,12 @@ AC_LANG_POP(C)
396396
if test $has_function = 1; then
397397
AC_MSG_RESULT([yes])
398398
AC_DEFINE([HAS_X509_check_host], [], [Define if ssl library has X509_check_host])
399+
OPENSSL_HOSTNAME_VALIDATION_OBJ=""
399400
else
400401
AC_MSG_RESULT([no])
402+
OPENSSL_HOSTNAME_VALIDATION_OBJ="openssl_hostname_validation.o"
401403
fi
404+
AC_SUBST(OPENSSL_HOSTNAME_VALIDATION_OBJ)
402405
])
403406

404407
dnl For geoip-api-c

configure

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ PCRE2_CFLAGS
675675
PKG_CONFIG_LIBDIR
676676
PKG_CONFIG_PATH
677677
PKG_CONFIG
678+
OPENSSL_HOSTNAME_VALIDATION_OBJ
678679
LDFLAGS_PRIVATELIBS
679680
CONTROLFILE
680681
PIDFILE
@@ -8251,11 +8252,14 @@ printf "%s\n" "yes" >&6; }
82518252

82528253
printf "%s\n" "#define HAS_X509_check_host /**/" >>confdefs.h
82538254

8255+
OPENSSL_HOSTNAME_VALIDATION_OBJ=""
82548256
else
82558257
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
82568258
printf "%s\n" "no" >&6; }
8259+
OPENSSL_HOSTNAME_VALIDATION_OBJ="openssl_hostname_validation.o"
82578260
fi
82588261

8262+
82598263
# Check whether --enable-dynamic-linking was given.
82608264
if test ${enable_dynamic_linking+y}
82618265
then :

src/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OBJS=ircd_vars.o dns.o auth.o channel.o dbuf.o \
3333
api-event.o api-rpc.o api-apicallback.o \
3434
crypt_blowfish.o unrealdb.o crashreport.o modulemanager.o \
3535
utf8.o json.o log.o \
36-
openssl_hostname_validation.o $(URL)
36+
@OPENSSL_HOSTNAME_VALIDATION_OBJ@ $(URL)
3737

3838
SRC=$(OBJS:%.o=%.c)
3939

src/openssl_hostname_validation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ SOFTWARE.
287287
*/
288288
static HostnameValidationResult matches_common_name(const char *hostname, const X509 *server_cert) {
289289
int common_name_loc = -1;
290-
X509_NAME_ENTRY *common_name_entry = NULL;
291-
ASN1_STRING *common_name_asn1 = NULL;
290+
const X509_NAME_ENTRY *common_name_entry = NULL;
291+
const ASN1_STRING *common_name_asn1 = NULL;
292292
const char *common_name_str = NULL;
293293

294294
// Find the position of the CN field in the Subject field of the certificate

src/tls.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
#include "unrealircd.h"
2626
#include "openssl_hostname_validation.h"
2727

28+
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
29+
#define OSSL_CONST const
30+
#else
31+
#define OSSL_CONST
32+
#endif
33+
2834
#ifdef _WIN32
2935
#define IDC_PASS 1166
3036
extern HINSTANCE hInst;
@@ -1342,7 +1348,7 @@ const char *certificate_name(SSL *ssl)
13421348
{
13431349
static char buf[384];
13441350
X509 *cert;
1345-
X509_NAME *n;
1351+
OSSL_CONST X509_NAME *n;
13461352

13471353
if (!ssl)
13481354
return NULL;

0 commit comments

Comments
 (0)