diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-12-23 16:06:05 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-02-18 16:50:12 +0100 |
commit | daf1300b80443b6bf0dec19085056ec407925d89 (patch) | |
tree | 037789ed2404c3265d4ae1592266744924b6a980 /crypto/cmp/cmp_ctx.c | |
parent | 937984efc6ed1664e5aeb0e06067d31520066960 (diff) |
Add internal X509_add_certs_new(), which simplifies matters
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14039)
Diffstat (limited to 'crypto/cmp/cmp_ctx.c')
-rw-r--r-- | crypto/cmp/cmp_ctx.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/crypto/cmp/cmp_ctx.c b/crypto/cmp/cmp_ctx.c index 26274611a8..e65dabe323 100644 --- a/crypto/cmp/cmp_ctx.c +++ b/crypto/cmp/cmp_ctx.c @@ -12,7 +12,6 @@ #include <openssl/trace.h> #include <openssl/bio.h> #include <openssl/ocsp.h> /* for OCSP_REVOKED_STATUS_* */ -#include "crypto/x509.h" /* for x509v3_cache_extensions() */ #include "cmp_local.h" @@ -65,15 +64,14 @@ STACK_OF(X509) *OSSL_CMP_CTX_get0_untrusted(const OSSL_CMP_CTX *ctx) */ int OSSL_CMP_CTX_set1_untrusted(OSSL_CMP_CTX *ctx, STACK_OF(X509) *certs) { - STACK_OF(X509) *untrusted; + STACK_OF(X509) *untrusted = NULL; + if (ctx == NULL) { ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT); return 0; } - if ((untrusted = sk_X509_new_null()) == NULL) - return 0; - if (X509_add_certs(untrusted, certs, - X509_ADD_FLAG_UP_REF | X509_ADD_FLAG_NO_DUP) != 1) + if (!ossl_x509_add_certs_new(&untrusted, certs, + X509_ADD_FLAG_UP_REF | X509_ADD_FLAG_NO_DUP)) goto err; sk_X509_pop_free(ctx->untrusted, X509_free); ctx->untrusted = untrusted; @@ -731,10 +729,8 @@ int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted, return 0; } - if (ctx->untrusted != NULL ? - !X509_add_certs(ctx->untrusted, candidates, - X509_ADD_FLAG_UP_REF | X509_ADD_FLAG_NO_DUP) : - !OSSL_CMP_CTX_set1_untrusted(ctx, candidates)) + if (!ossl_x509_add_certs_new(&ctx->untrusted, candidates, + X509_ADD_FLAG_UP_REF | X509_ADD_FLAG_NO_DUP)) return 0; ossl_cmp_debug(ctx, "trying to build chain for own CMP signer cert"); |