summaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorViktor Dukhovni <openssl-users@dukhovni.org>2016-01-16 00:08:38 -0500
committerViktor Dukhovni <openssl-users@dukhovni.org>2016-01-20 19:04:26 -0500
commit0996dc5440cc233f029129182bbb6e3d4613045a (patch)
tree7b54822da3319212fc52d6b9e1d463c770fa0495 /apps/apps.c
parent6e8beabcd4b9450a3a7358bf5668b2bc70580517 (diff)
Refactor apps load_certs/load_crls to work incrementally
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/apps/apps.c b/apps/apps.c
index bb47039ce0..9b55f820e1 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -921,13 +921,13 @@ static int load_certs_crls(const char *file, int format,
BIO_free(bio);
- if (pcerts) {
+ if (pcerts && *pcerts == NULL) {
*pcerts = sk_X509_new_null();
if (!*pcerts)
goto end;
}
- if (pcrls) {
+ if (pcrls && *pcrls == NULL) {
*pcrls = sk_X509_CRL_new_null();
if (!*pcrls)
goto end;
@@ -986,24 +986,22 @@ void* app_malloc(int sz, const char *what)
return vp;
}
-
-
-STACK_OF(X509) *load_certs(const char *file, int format,
- const char *pass, ENGINE *e, const char *desc)
+/*
+ * Initialize or extend, if *certs != NULL, a certificate stack.
+ */
+int load_certs(const char *file, STACK_OF(X509) **certs, int format,
+ const char *pass, ENGINE *e, const char *desc)
{
- STACK_OF(X509) *certs;
- if (!load_certs_crls(file, format, pass, e, desc, &certs, NULL))
- return NULL;
- return certs;
+ return load_certs_crls(file, format, pass, e, desc, certs, NULL);
}
-STACK_OF(X509_CRL) *load_crls(const char *file, int format,
- const char *pass, ENGINE *e, const char *desc)
+/*
+ * Initialize or extend, if *crls != NULL, a certificate stack.
+ */
+int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
+ const char *pass, ENGINE *e, const char *desc)
{
- STACK_OF(X509_CRL) *crls;
- if (!load_certs_crls(file, format, pass, e, desc, NULL, &crls))
- return NULL;
- return crls;
+ return load_certs_crls(file, format, pass, e, desc, NULL, crls);
}
#define X509V3_EXT_UNKNOWN_MASK (0xfL << 16)