Blame SOURCES/nginx-1.16.0-pkcs11.patch

2ace6e
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
2ace6e
index 7be4fb4..ab3865a 100644
2ace6e
--- a/src/event/ngx_event_openssl.c
2ace6e
+++ b/src/event/ngx_event_openssl.c
2ace6e
@@ -727,16 +727,24 @@ ngx_ssl_load_certificate_key(ngx_pool_t *pool, char **err,
2ace6e
             return NULL;
2ace6e
         }
2ace6e
 
2ace6e
+        if (!ENGINE_init(engine)) {
2ace6e
+            *err = "ENGINE_init() failed";
2ace6e
+            ENGINE_free(engine);
2ace6e
+            return NULL;
2ace6e
+        }
2ace6e
+
2ace6e
         *last++ = ':';
2ace6e
 
2ace6e
         pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0);
2ace6e
 
2ace6e
         if (pkey == NULL) {
2ace6e
             *err = "ENGINE_load_private_key() failed";
2ace6e
+            ENGINE_finish(engine);
2ace6e
             ENGINE_free(engine);
2ace6e
             return NULL;
2ace6e
         }
2ace6e
 
2ace6e
+        ENGINE_finish(engine);
2ace6e
         ENGINE_free(engine);
2ace6e
 
2ace6e
         return pkey;