From: Matt Caswell Date: Tue, 27 Jul 2021 15:36:24 +0000 (+0100) Subject: Ensure any default_properties still apply even in the event of a provider load failure X-Git-Tag: openssl-3.0.0-beta2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=123ed334337e874acb1f55b36dc671de7e306824;p=thirdparty%2Fopenssl.git Ensure any default_properties still apply even in the event of a provider load failure We don't treat a failure to load a provider as a fatal error. If it is fatal then we give up attempting to load the config file - including reading any default properties. Additionally if an attempt has been made to load a provider then we disable fallback loading. Fixes #16166 Reviewed-by: Tim Hudson Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/16168) --- diff --git a/crypto/provider_conf.c b/crypto/provider_conf.c index 1d4e695fb89..fe66e1158e7 100644 --- a/crypto/provider_conf.c +++ b/crypto/provider_conf.c @@ -156,6 +156,16 @@ static int provider_conf_load(OSSL_LIB_CTX *libctx, const char *name, } if (activate) { + /* + * There is an attempt to activate a provider, so we should disable + * loading of fallbacks. Otherwise a misconfiguration could mean the + * intended provider does not get loaded. Subsequent fetches could then + * fallback to the default provider - which may be the wrong thing. + */ + if (!ossl_provider_disable_fallback_loading(libctx)) { + ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); + return 0; + } prov = ossl_provider_find(libctx, name, 1); if (prov == NULL) prov = ossl_provider_new(libctx, name, NULL, 1); @@ -215,7 +225,11 @@ static int provider_conf_load(OSSL_LIB_CTX *libctx, const char *name, } - return ok; + /* + * Even if ok is 0, we still return success. Failure to load a provider is + * not fatal. We want to continue to load the rest of the config file. + */ + return 1; } static int provider_conf_init(CONF_IMODULE *md, const CONF *cnf)