diff --git a/src/eng_front.c b/src/eng_front.c index 5fe8f55..286aaa9 100644 --- a/src/eng_front.c +++ b/src/eng_front.c @@ -233,11 +233,9 @@ static EVP_PKEY *load_privkey(ENGINE *engine, const char *s_key_id, #ifdef EVP_F_EVP_PKEY_SET1_ENGINE /* EVP_PKEY_set1_engine() is required for OpenSSL 1.1.x, * but otherwise setting pkey->engine breaks OpenSSL 1.0.2 */ - if (pkey) { - if (!EVP_PKEY_set1_engine(pkey, engine)) { - EVP_PKEY_free(pkey); - return NULL; - } + if (pkey && !EVP_PKEY_set1_engine(pkey, engine)) { + EVP_PKEY_free(pkey); + pkey = NULL; } #endif /* EVP_F_EVP_PKEY_SET1_ENGINE */ return pkey;