Blame SOURCES/nginx-1.14.0-pkcs11.patch

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