From 18b67d6eafbecb8ff3f6cb514594d115e099117d Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Fri, 11 Oct 2019 01:59:34 +0300 Subject: [PATCH] tls/openssl: add LibreSSL support OpenSSL and LibreSSL versions are incompatible. Moreover, LibreSSL always define OPENSSL_VERSION_NUMBER as 0x20000000L. Instead of checking for LibreSSL everywhere explicitly, redefine OPENSSL_VERSION_NUMBER. See similar issues with nginx project: https://trac.nginx.org/nginx/ticket/1605 --- src/tls_openssl.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tls_openssl.c b/src/tls_openssl.c index 9d55e36..503084d 100644 --- a/src/tls_openssl.c +++ b/src/tls_openssl.c @@ -31,6 +31,22 @@ #include "tls.h" #include "sock.h" +/* + * Redefine OPENSSL_VERSION_NUMBER for LibreSSL. + * LibreSSL and OpenSSL use different and incompatible version schemes. Solve + * this issue in the way how nginx project did. + */ +#if (defined LIBRESSL_VERSION_NUMBER && OPENSSL_VERSION_NUMBER == 0x20000000L) +#undef OPENSSL_VERSION_NUMBER +#if (LIBRESSL_VERSION_NUMBER >= 0x2080000fL) +#define OPENSSL_VERSION_NUMBER 0x1010000fL +#elif (LIBRESSL_VERSION_NUMBER >= 0x2070000fL) +#define OPENSSL_VERSION_NUMBER 0x1000200fL +#else +#define OPENSSL_VERSION_NUMBER 0x1000107fL +#endif +#endif + struct _tls { xmpp_ctx_t *ctx; sock_t sock;