Skip to content

Commit 5724e00

Browse files
committed
x509storeissuer: report the store size before the test run if the verbosity level is DEBUG_STATS or higher
Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent fc6682d commit 5724e00

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

source/x509storeissuer.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,27 @@ do_x509storeissuer(size_t num)
320320
founds[num] = found;
321321
}
322322

323+
static void
324+
report_store_size(X509_STORE * const store, const char * const suffix,
325+
int verbosity)
326+
{
327+
if (verbosity >= VERBOSITY_DEBUG_STATS) {
328+
STACK_OF(X509_OBJECT) *sk =
329+
#if OPENSSL_VERSION_NUMBER >= 0x30300000L
330+
X509_STORE_get1_objects(store);
331+
#else
332+
X509_STORE_get0_objects(store);
333+
#endif
334+
335+
fprintf(stderr, "Number of certificates in the store %s: %d\n",
336+
suffix, sk_X509_OBJECT_num(sk));
337+
338+
#if OPENSSL_VERSION_NUMBER >= 0x30300000L
339+
sk_X509_OBJECT_pop_free(sk, X509_OBJECT_free);
340+
#endif
341+
}
342+
}
343+
323344
static void
324345
usage(char * const argv[])
325346
{
@@ -479,6 +500,8 @@ main(int argc, char *argv[])
479500
if (founds == NULL)
480501
errx(EXIT_FAILURE, "Failed to create founds array");
481502

503+
report_store_size(store, "before the test run", verbosity);
504+
482505
x509_nonce = make_nonce(&nonce_cfg);
483506
if (x509_nonce == NULL)
484507
errx(EXIT_FAILURE, "Unable to create the nonce X509 object");

0 commit comments

Comments
 (0)