From 059d888015bec2e14aa0b1405deab3eecd9272da Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Tue, 10 Jan 2023 18:33:51 +0100 Subject: [PATCH] libssl: Cleanup TLS engine loading --- pdns/libssl.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 1103325708..3e3bdc9220 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -80,7 +80,7 @@ static void openssl_thread_cleanup() static std::atomic s_users; #ifndef OPENSSL_NO_ENGINE -static LockGuarded>> s_engines; +static LockGuarded>> s_engines; #endif static int s_ticketsKeyIndex{-1}; static int s_countersIndex{-1}; @@ -182,14 +182,11 @@ std::pair libssl_load_engine(const std::string& engineName, c return { false, "TLS engine already loaded" }; } - ENGINE* enginePtr = ENGINE_by_id(engineName.c_str()); - if (enginePtr == nullptr) { + auto engine = std::unique_ptr(ENGINE_by_id(engineName.c_str()), ENGINE_free); + if (engine == nullptr) { return { false, "unable to load TLS engine '" + engineName + "'" }; } - auto engine = std::unique_ptr(enginePtr, ENGINE_free); - enginePtr = nullptr; - if (!ENGINE_init(engine.get())) { return { false, "Unable to init TLS engine '" + engineName + "'" }; } -- 2.47.2