summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-04-26 18:30:45 +0200
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>2020-08-12 13:54:37 +0200
commiteeccc237239d6f2b6fbc557be7062bfe2ab836be (patch)
tree888f18ed5067404a0703b62f94a263317109f5be /crypto/pkcs7
parente3efe7a53299dff3cd2222542b6a999b1360d626 (diff)
Introduce X509_add_cert[s] simplifying various additions to cert lists
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12615)
Diffstat (limited to 'crypto/pkcs7')
-rw-r--r--crypto/pkcs7/pk7_lib.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c
index abe3570c68..797d1d2c25 100644
--- a/crypto/pkcs7/pk7_lib.c
+++ b/crypto/pkcs7/pk7_lib.c
@@ -13,7 +13,7 @@
#include <openssl/x509.h>
#include "crypto/asn1.h"
#include "crypto/evp.h"
-#include "crypto/x509.h"
+#include "crypto/x509.h" /* for sk_X509_add1_cert() */
#include "pk7_local.h"
DEFINE_STACK_OF(X509)
@@ -262,18 +262,7 @@ int PKCS7_add_certificate(PKCS7 *p7, X509 *x509)
return 0;
}
- if (*sk == NULL)
- *sk = sk_X509_new_null();
- if (*sk == NULL) {
- PKCS7err(PKCS7_F_PKCS7_ADD_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- return 0;
- }
- X509_up_ref(x509);
- if (!sk_X509_push(*sk, x509)) {
- X509_free(x509);
- return 0;
- }
- return 1;
+ return X509_add_cert_new(sk, x509, X509_ADD_FLAG_UP_REF);
}
int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl)