32bf4d
# HG changeset patch
32bf4d
# User Anderson Sasaki <ansasaki@redhat.com>
32bf4d
# Date 1533742801 -7200
32bf4d
#      Wed Aug 08 17:40:01 2018 +0200
32bf4d
# Node ID ae457c9b2967da1b05aefcf1e81c099e9375c0d7
32bf4d
# Parent  ba971deb4b447662e3c47fcc860b34d43469162a
32bf4d
SSL: added ENGINE_init() call before loading key.
32bf4d
32bf4d
It is necessary to call ENGINE_init() before using an OpenSSL engine
32bf4d
to get the engine functional reference.  Without this, when
32bf4d
ENGINE_load_private_key() is called, the engine is still uninitialized.
32bf4d
32bf4d
diff -r ba971deb4b44 -r ae457c9b2967 src/event/ngx_event_openssl.c
32bf4d
--- a/src/event/ngx_event_openssl.c	Tue Aug 07 02:16:07 2018 +0300
32bf4d
+++ b/src/event/ngx_event_openssl.c	Wed Aug 08 17:40:01 2018 +0200
32bf4d
@@ -533,6 +533,13 @@
32bf4d
             return NGX_ERROR;
32bf4d
         }
32bf4d
 
32bf4d
+        if (!ENGINE_init(engine)) {
32bf4d
+            ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
32bf4d
+                          "ENGINE_init(\"%s\") failed", p);
32bf4d
+            ENGINE_free(engine);
32bf4d
+            return NGX_ERROR;
32bf4d
+        }
32bf4d
+
32bf4d
         *last++ = ':';
32bf4d
 
32bf4d
         pkey = ENGINE_load_private_key(engine, (char *) last, 0, 0);
32bf4d
@@ -540,10 +547,12 @@
32bf4d
         if (pkey == NULL) {
32bf4d
             ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
32bf4d
                           "ENGINE_load_private_key(\"%s\") failed", last);
32bf4d
+            ENGINE_finish(engine);
32bf4d
             ENGINE_free(engine);
32bf4d
             return NGX_ERROR;
32bf4d
         }
32bf4d
 
32bf4d
+        ENGINE_finish(engine);
32bf4d
         ENGINE_free(engine);
32bf4d
 
32bf4d
         if (SSL_CTX_use_PrivateKey(ssl->ctx, pkey) == 0) {