Blame SOURCES/nginx-1.16.0-pkcs11.patch

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