mirror of
https://github.com/openssl/openssl.git
synced 2024-11-27 05:21:51 +08:00
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 <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15820)
This commit is contained in:
parent
a1a62437e9
commit
ecd699b6da
@ -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 (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?");
|
||||
if (no_loader_found)
|
||||
/*
|
||||
* It's assumed that ossl_store_get0_loader_int() and
|
||||
* OSSL_STORE_LOADER_fetch() report their own errors
|
||||
*/
|
||||
goto err;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user