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