From c22f2757449f47ce661b3cdbb8a105d7721b4a5a Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sat, 9 Jul 2022 23:27:23 +0300 Subject: [PATCH] Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility) Since OpenSSL 3.0 there is new OPENSSL_VERSION_MAJOR, but previous releases does not have it. So let's use plain old OPENSSL_VERSION_NUMBER to avoid more preprocessor macros. --- sample/becat.c | 4 ++-- sample/le-proxy.c | 2 +- test/regress_ssl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sample/becat.c b/sample/becat.c index c6daf90a..501690da 100644 --- a/sample/becat.c +++ b/sample/becat.c @@ -188,7 +188,7 @@ static void ssl_ctx_free(struct ssl_context *ssl) static int ssl_load_key(struct ssl_context *ssl) { int err = 1; -#if OPENSSL_VERSION_MAJOR >= 3 +#if OPENSSL_VERSION_NUMBER >= 0x30000000 ssl->pkey = EVP_RSA_gen(4096); err = ssl->pkey == NULL; #else @@ -391,7 +391,7 @@ static void be_ssl_errors(struct bufferevent *bev) while ((err = bufferevent_get_openssl_error(bev))) { const char *msg = ERR_reason_error_string(err); const char *lib = ERR_lib_error_string(err); -#if OPENSSL_VERSION_MAJOR >= 3 +#if OPENSSL_VERSION_NUMBER >= 0x30000000 error("ssl/err=%d/%s in %s\n", err, msg, lib); #else const char *func = ERR_func_error_string(err); diff --git a/sample/le-proxy.c b/sample/le-proxy.c index 881d3a59..1aa7d648 100644 --- a/sample/le-proxy.c +++ b/sample/le-proxy.c @@ -113,7 +113,7 @@ eventcb(struct bufferevent *bev, short what, void *ctx) ERR_reason_error_string(err); const char *lib = (const char*) ERR_lib_error_string(err); -#if OPENSSL_VERSION_MAJOR >= 3 +#if OPENSSL_VERSION_NUMBER >= 0x30000000 fprintf(stderr, "%s in %s\n", msg, lib); #else diff --git a/test/regress_ssl.c b/test/regress_ssl.c index a27f225a..55ea7e61 100644 --- a/test/regress_ssl.c +++ b/test/regress_ssl.c @@ -224,7 +224,7 @@ eventcb(struct bufferevent *bev, short what, void *ctx) ++n_connected; ssl = bufferevent_ssl_get_ssl(bev); tt_assert(ssl); -#if OPENSSL_VERSION_MAJOR >= 3 +#if OPENSSL_VERSION_NUMBER >= 0x30000000 /* SSL_get1_peer_certificate() means we want * to increase the reference count on the cert * and so we will need to free it ourselves later