From 5d78643e29766439b89f7a80b923ec78acf69d86 Mon Sep 17 00:00:00 2001 From: zhaozg Date: Sat, 2 Sep 2023 10:58:50 +0800 Subject: [PATCH] fixup OpenSSL cleanup --- src/openssl.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openssl.c b/src/openssl.c index cb7dbde9..79bbabe5 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -420,8 +420,10 @@ static void openssl_finalize(void) #if (OPENSSL_VERSION_NUMBER > 0x10100000L && !IS_LIBRESSL()) || \ LIBRESSL_VERSION_NUMBER > 0x30600000L #if !IS_LIBRESSL() + /* This will be called automatically by the library when the thread exits. */ OPENSSL_thread_stop(); #endif + /* This is initiated automatically on application exit */ OPENSSL_cleanup(); #else @@ -476,7 +478,11 @@ static void openssl_initialize() { if (_guard) return; _guard = 1; +#if (OPENSSL_VERSION_NUMBER < 0x10100000L || \ + (IS_LIBRESSL() && LIBRESSL_VERSION_NUMBER < 0x30600000L)) + /* Automatically do thread and resources cleanup above OpenSSL v1.1.1 */ atexit(openssl_finalize); +#endif #if defined(OPENSSL_THREADS) && \ (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER))