Skip to content

Commit 29cb2c2

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 892152a commit 29cb2c2

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
@@ -178,6 +178,27 @@ do_x509storeissuer(size_t num)
178178
founds[num] = found;
179179
}
180180

181+
static void
182+
report_store_size(X509_STORE * const store, const char * const suffix,
183+
int verbosity)
184+
{
185+
if (verbosity >= VERBOSITY_DEBUG_STATS) {
186+
STACK_OF(X509_OBJECT) *sk =
187+
#if OPENSSL_VERSION_NUMBER >= 0x30300000L
188+
X509_STORE_get1_objects(store);
189+
#else
190+
X509_STORE_get0_objects(store);
191+
#endif
192+
193+
fprintf(stderr, "Number of certificates in the store %s: %d\n",
194+
suffix, sk_X509_OBJECT_num(sk));
195+
196+
#if OPENSSL_VERSION_NUMBER >= 0x30300000L
197+
sk_X509_OBJECT_pop_free(sk, X509_OBJECT_free);
198+
#endif
199+
}
200+
}
201+
181202
static void
182203
usage(char * const argv[])
183204
{
@@ -410,6 +431,8 @@ main(int argc, char *argv[])
410431
if (founds == NULL)
411432
errx(EXIT_FAILURE, "Failed to create founds array");
412433

434+
report_store_size(store, "before the test run", verbosity);
435+
413436
x509_nonce = make_nonce(&nonce_cfg);
414437
if (x509_nonce == NULL)
415438
errx(EXIT_FAILURE, "Unable to create the nonce X509 object");

0 commit comments

Comments
 (0)