summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-09-28 21:28:00 +0200
committerRichard Levitte <richard@levitte.org>2016-09-28 21:58:50 +0200
commita1b791225f2913ace014071bfb9099790ef468e5 (patch)
tree4a36fbc6f5549bb9c833e8adda8a2ceb86d29b02 /apps
parent8061fdc8d3048220a758ad1304669944810ac386 (diff)
apps/apps.c: initialize and de-initialize engine around key loading
Before loading a key from an engine, it may need to be initialized. When done loading the key, we must de-initialize the engine. (if the engine is already initialized somehow, only the reference counter will be incremented then decremented) Reviewed-by: Stephen Henson <steve@openssl.org> (cherry picked from commit 49e476a5382602d0bad1139d6f1f66ddbc7959d6)
Diffstat (limited to 'apps')
-rw-r--r--apps/apps.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/apps/apps.c b/apps/apps.c
index aa564b8e8f..96184a6fb7 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -692,7 +692,10 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
BIO_printf(bio_err, "no engine specified\n");
else {
#ifndef OPENSSL_NO_ENGINE
- pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
+ if (ENGINE_init(e)) {
+ pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
+ ENGINE_finish(e);
+ }
if (pkey == NULL) {
BIO_printf(bio_err, "cannot load %s from engine\n", key_descrip);
ERR_print_errors(bio_err);