From: Richard Levitte Date: Thu, 7 Mar 2019 14:27:15 +0000 (+0100) Subject: OSSL_STORE: add tracing X-Git-Tag: openssl-3.0.0-alpha1~1035 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2897b00905afdb53458dde387729568342d8910c;p=oweals%2Fopenssl.git OSSL_STORE: add tracing Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/8442) --- diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 84f768bb5b..d39967ccc4 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -16,6 +16,7 @@ #include #include +#include #include #include "internal/thread_once.h" #include "crypto/store.h" @@ -74,9 +75,14 @@ OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method, /* Try each scheme until we find one that could open the URI */ for (i = 0; loader_ctx == NULL && i < schemes_n; i++) { - if ((loader = ossl_store_get0_loader_int(schemes[i])) != NULL) + OSSL_TRACE1(STORE, "Looking up scheme %s\n", schemes[i]); + if ((loader = ossl_store_get0_loader_int(schemes[i])) != NULL) { + OSSL_TRACE1(STORE, "Found loader for scheme %s\n", schemes[i]); loader_ctx = loader->open(loader, uri, ui_method, ui_data); + OSSL_TRACE2(STORE, "Opened %s => %p\n", uri, (void *)loader_ctx); + } } + if (loader_ctx == NULL) goto err; @@ -172,6 +178,7 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx) if (OSSL_STORE_eof(ctx)) return NULL; + OSSL_TRACE(STORE, "Loading next object\n"); v = ctx->loader->load(ctx->loader_ctx, ctx->ui_method, ctx->ui_data); if (ctx->post_process != NULL && v != NULL) { @@ -203,6 +210,10 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx) } } + if (v != NULL) + OSSL_TRACE1(STORE, "Got a %s\n", + OSSL_STORE_INFO_type_string(OSSL_STORE_INFO_get_type(v))); + return v; } @@ -218,7 +229,10 @@ int OSSL_STORE_eof(OSSL_STORE_CTX *ctx) int OSSL_STORE_close(OSSL_STORE_CTX *ctx) { - int loader_ret = ctx->loader->close(ctx->loader_ctx); + int loader_ret; + + OSSL_TRACE1(STORE, "Closing %p\n", (void *)ctx->loader_ctx); + loader_ret = ctx->loader->close(ctx->loader_ctx); OPENSSL_free(ctx); return loader_ret; diff --git a/crypto/trace.c b/crypto/trace.c index 7ff6af8837..18a8c64135 100755 --- a/crypto/trace.c +++ b/crypto/trace.c @@ -133,6 +133,7 @@ static const struct trace_category_st trace_categories[] = { TRACE_CATEGORY_(PKCS12_DECRYPT), TRACE_CATEGORY_(X509V3_POLICY), TRACE_CATEGORY_(BN_CTX), + TRACE_CATEGORY_(STORE), }; const char *OSSL_trace_get_category_name(int num) diff --git a/include/openssl/trace.h b/include/openssl/trace.h index 31e6fcc3f5..f71d9fb4ca 100644 --- a/include/openssl/trace.h +++ b/include/openssl/trace.h @@ -50,7 +50,8 @@ extern "C" { # define OSSL_TRACE_CATEGORY_X509V3_POLICY 11 # define OSSL_TRACE_CATEGORY_BN_CTX 12 # define OSSL_TRACE_CATEGORY_CMP 13 -# define OSSL_TRACE_CATEGORY_NUM 14 +# define OSSL_TRACE_CATEGORY_STORE 14 +# define OSSL_TRACE_CATEGORY_NUM 15 /* Returns the trace category number for the given |name| */ int OSSL_trace_get_category_num(const char *name);