ignatenkobrain / rpms / nginx

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