The branch master has been updated via ecd699b6dae054d368ca9ff04f3b80013f3c241f (commit) from a1a62437e96ce4c1ba807e99a8231560f4ba59ef (commit)
- Log ----------------------------------------------------------------- commit ecd699b6dae054d368ca9ff04f3b80013f3c241f Author: Richard Levitte <levi...@openssl.org> Date: Fri Jun 18 07:09:25 2021 +0200 STORE: Fix OSSL_STORE_open_ex() error reporting OSSL_STORE_open_ex() could result in reports like this: 80722AA3927F0000:error:80000002:system library:file_open_ex:No such file or directory:engines/e_loader_attic.c:1016:calling stat(file:test/blahdibleh.der) 80722AA3927F0000:error:41800069:lib(131)::path must be absolute:engines/e_loader_attic.c:1010:test/blahdibleh.der 80722AA3927F0000:error:1600007B:STORE routines:OSSL_STORE_open_ex:no loaders found:crypto/store/store_lib.c:148:No store loaders were found. For standard store loaders you need at least one of the default or base providers available. Did you forget to load them? The last one turns out to be a bit too generically reported. It should only be reported when no loader were loaded at all, not when loader_ctx happens to be NULL (which may happen for other reasons). We also move the helpful message to the OSSL_STORE_LOADER fetcher. Reviewed-by: Tomas Mraz <to...@openssl.org> Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15820) ----------------------------------------------------------------------- Summary of changes: crypto/store/store_lib.c | 24 ++++++++++++++++-------- crypto/store/store_meth.c | 9 ++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index c0d9dafbdf..4b31c6f7d5 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -71,6 +71,7 @@ OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, OSSL_STORE_LOADER_CTX *loader_ctx = NULL; OSSL_STORE_CTX *ctx = NULL; char *propq_copy = NULL; + int no_loader_found = 1; char scheme_copy[256], *p, *schemes[2]; size_t schemes_n = 0; size_t i; @@ -113,6 +114,7 @@ OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, OSSL_TRACE1(STORE, "Looking up scheme %s\n", schemes[i]); #ifndef OPENSSL_NO_DEPRECATED_3_0 if ((loader = ossl_store_get0_loader_int(schemes[i])) != NULL) { + no_loader_found = 0; if (loader->open_ex != NULL) loader_ctx = loader->open_ex(loader, uri, libctx, propq, ui_method, ui_data); @@ -127,6 +129,7 @@ OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, OSSL_STORE_LOADER_get0_provider(fetched_loader); void *provctx = OSSL_PROVIDER_get0_provider_ctx(provider); + no_loader_found = 0; loader_ctx = fetched_loader->p_open(provctx, uri); if (loader_ctx == NULL) { OSSL_STORE_LOADER_free(fetched_loader); @@ -141,16 +144,21 @@ OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq, } } - if (loader != NULL) - OSSL_TRACE1(STORE, "Found loader for scheme %s\n", schemes[i]); + if (no_loader_found) + /* + * It's assumed that ossl_store_get0_loader_int() and + * OSSL_STORE_LOADER_fetch() report their own errors + */ + goto err; - if (loader_ctx == NULL) { - ERR_raise_data(ERR_LIB_OSSL_STORE, OSSL_STORE_R_NO_LOADERS_FOUND, - "No store loaders were found. For standard store " - "loaders you need at least one of the default or base " - "providers available. Did you forget to load them?"); + OSSL_TRACE1(STORE, "Found loader for scheme %s\n", schemes[i]); + + if (loader_ctx == NULL) + /* + * It's assumed that the loader's open() method reports its own + * errors + */ goto err; - } OSSL_TRACE2(STORE, "Opened %s => %p\n", uri, (void *)loader_ctx); diff --git a/crypto/store/store_meth.c b/crypto/store/store_meth.c index e316f4f139..61230a6c24 100644 --- a/crypto/store/store_meth.c +++ b/crypto/store/store_meth.c @@ -344,11 +344,18 @@ inner_loader_fetch(struct loader_data_st *methdata, int id, if ((id != 0 || scheme != NULL) && method == NULL) { int code = unsupported ? ERR_R_UNSUPPORTED : ERR_R_FETCH_FAILED; + const char *helpful_msg = + unsupported + ? ( "No store loader found. For standard store loaders you need " + "at least one of the default or base providers available. " + "Did you forget to load them? Info: " ) + : ""; if (scheme == NULL) scheme = ossl_namemap_num2name(namemap, id, 0); ERR_raise_data(ERR_LIB_OSSL_STORE, code, - "%s, Scheme (%s : %d), Properties (%s)", + "%s%s, Scheme (%s : %d), Properties (%s)", + helpful_msg, ossl_lib_ctx_get_descriptor(methdata->libctx), scheme = NULL ? "<null>" : scheme, id, properties == NULL ? "<null>" : properties);