]> granicus.if.org Git - libevent/commitdiff
Fix build with LibreSSL 2.7
authorBernard Spil <brnrd@FreeBSD.org>
Mon, 2 Apr 2018 11:18:27 +0000 (13:18 +0200)
committerAzat Khuzhin <azat@libevent.org>
Sat, 2 Feb 2019 12:17:55 +0000 (15:17 +0300)
LibreSSL 2.7 implements OpenSSL 1.1 API except for BIO_get_init()

See also: https://bugs.freebsd.org/226900
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
Closes: #617 (cherry-pick)
(cherry picked from commit 28b8075400c70b2d2da2ce07e590c2ec6d11783d)

openssl-compat.h
sample/https-client.c
sample/le-proxy.c
sample/openssl_hostname_validation.c
test/regress_ssl.c

index bffd2593d0cded7b8ec81791a28889b382aa2756..5d91ac6402d8cf3d007f28ac8f72446dfb0d1402 100644 (file)
@@ -4,7 +4,8 @@
 #include <openssl/bio.h>
 #include "util-internal.h"
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
 
 static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
 {
@@ -33,6 +34,11 @@ static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
 
 #define TLS_method SSLv23_method
 
-#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) */
+#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
+
+#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
+#define BIO_get_init(b) (b)->init
+#endif
 
 #endif /* OPENSSL_COMPAT_H */
index 8ef75987ba02a3faec388dea84466bca584ba7fd..4292f0942b5a0cceac1b7a1e511d78a62a89ecc8 100644 (file)
@@ -312,7 +312,8 @@ main(int argc, char **argv)
        }
        uri[sizeof(uri) - 1] = '\0';
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
        // Initialize OpenSSL
        SSL_library_init();
        ERR_load_crypto_strings();
@@ -488,7 +489,8 @@ cleanup:
                SSL_CTX_free(ssl_ctx);
        if (type == HTTP && ssl)
                SSL_free(ssl);
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
        EVP_cleanup();
        ERR_free_strings();
 
@@ -501,7 +503,8 @@ cleanup:
        CRYPTO_cleanup_all_ex_data();
 
        sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
-#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER) */
+#endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
 
 #ifdef _WIN32
        WSACleanup();
index 4e1cf03390f8302909394a3562aa66d0e43896d9..73c488817354a238194cf592fd30f37fb3209c7b 100644 (file)
@@ -261,7 +261,8 @@ main(int argc, char **argv)
 
        if (use_ssl) {
                int r;
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
                SSL_library_init();
                ERR_load_crypto_strings();
                SSL_load_error_strings();
index a60e38c4e0f9330039d709928047e0e339d094e3..4036ccbaabc9356cae62f408a1175accfd8f6e94 100644 (file)
@@ -48,7 +48,8 @@ SOFTWARE.
 
 #define HOSTNAME_MAX_SIZE 255
 
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
 #define ASN1_STRING_get0_data ASN1_STRING_data
 #endif
 
index 5004f7e83f72052ba315f16dbd4f52ad5393a68a..92026976ec94c26be4724d692aa3d5927c69bdd5 100644 (file)
@@ -185,7 +185,8 @@ get_ssl_ctx(void)
 void
 init_ssl(void)
 {
-#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
+       (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
        SSL_library_init();
        ERR_load_crypto_strings();
        SSL_load_error_strings();