]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - crypto/store/store_lib.c
STORE: Fix OSSL_STORE_open_ex() error reporting
[thirdparty/openssl.git] / crypto / store / store_lib.c
index c0d9dafbdf38cd2800def240ffe293d8f501d062..4b31c6f7d5f76ce797cd96328879437f7e9cb57e 100644 (file)
@@ -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);