Skip to content

Commit

Permalink
apps/apps.c: initialize and de-initialize engine around key loading
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 49e476a)
  • Loading branch information
levitte committed Sep 28, 2016
1 parent a269e5f commit 53a71b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,10 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
if (!e)
BIO_printf(err, "no engine specified\n");
else {
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) {
BIO_printf(err, "cannot load %s from engine\n", key_descrip);
ERR_print_errors(err);
Expand Down

0 comments on commit 53a71b7

Please sign in to comment.