e9d4df
From a769a35a6197c76390e1dd8f5054d426fbbbda05 Mon Sep 17 00:00:00 2001
e9d4df
From: =?UTF-8?q?Lubo=C5=A1=20Uhliarik?= <luhliari@redhat.com>
e9d4df
Date: Wed, 22 Sep 2021 16:12:58 +0200
e9d4df
Subject: [PATCH] Init openssl engine properly
e9d4df
e9d4df
---
e9d4df
 src/event/ngx_event_openssl.c | 8 ++++++++
e9d4df
 1 file changed, 8 insertions(+)
e9d4df
e9d4df
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
e9d4df
index 270b200..f813458 100644
e9d4df
--- a/src/event/ngx_event_openssl.c
e9d4df
+++ b/src/event/ngx_event_openssl.c
e9d4df
@@ -798,16 +798,24 @@ ngx_ssl_load_certificate_key(ngx_pool_t *pool, char **err,
e9d4df
             return NULL;
e9d4df
         }
e9d4df
 
e9d4df
+        if (!ENGINE_init(engine)) {
e9d4df
+            *err = "ENGINE_init() failed";
e9d4df
+            ENGINE_free(engine);
e9d4df
+            return NULL;
e9d4df
+        }
e9d4df
+
e9d4df
         *last++ = ':';
e9d4df
 
e9d4df
         pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0);
e9d4df
 
e9d4df
         if (pkey == NULL) {
e9d4df
             *err = "ENGINE_load_private_key() failed";
e9d4df
+            ENGINE_finish(engine);
e9d4df
             ENGINE_free(engine);
e9d4df
             return NULL;
e9d4df
         }
e9d4df
 
e9d4df
+        ENGINE_finish(engine);
e9d4df
         ENGINE_free(engine);
e9d4df
 
e9d4df
         return pkey;
e9d4df
-- 
e9d4df
2.31.1
e9d4df