xref: /openssl/doc/man3/CMS_add0_cert.pod (revision 7ed6de99)
1=pod
2
3=head1 NAME
4
5CMS_add0_cert, CMS_add1_cert, CMS_get1_certs,
6CMS_add0_crl, CMS_add1_crl, CMS_get1_crls
7- CMS certificate and CRL utility functions
8
9=head1 SYNOPSIS
10
11 #include <openssl/cms.h>
12
13 int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
14 int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
15 STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
16
17 int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
18 int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
19 STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
20
21=head1 DESCRIPTION
22
23CMS_add0_cert() and CMS_add1_cert() add certificate I<cert> to I<cms>
24unless it is already present.
25This is used by L<CMS_sign_ex(3)> and L<CMS_sign(3)> and may be used before
26calling L<CMS_verify(3)> to help chain building in certificate validation.
27As the 0 implies, CMS_add0_cert() adds I<cert> internally to I<cms>
28and on success it must not be freed up by the caller.
29In contrast, the caller of CMS_add1_cert() must free I<cert>.
30I<cms> must be of type signed data or (authenticated) enveloped data.
31For signed data, such a certificate can be used when signing or verifying
32to fill in the signer certificate or to provide an extra CA certificate
33that may be needed for chain building in certificate validation.
34
35CMS_get1_certs() returns all certificates in I<cms>.
36
37CMS_add0_crl() and CMS_add1_crl() add CRL I<crl> to I<cms>.
38I<cms> must be of type signed data or (authenticated) enveloped data.
39For signed data, such a CRL may be used in certificate validation
40with L<CMS_verify(3)>.
41It may be given both for inclusion when signing a CMS message
42and when verifying a signed CMS message.
43
44CMS_get1_crls() returns all CRLs in I<cms>.
45
46=head1 NOTES
47
48The CMS_ContentInfo structure I<cms> must be of type signed data or enveloped
49data or authenticated enveloped data or an error will be returned.
50
51For signed data, certificates and CRLs are added to the I<certificates> and
52I<crls> fields of SignedData structure.
53For enveloped data they are added to B<OriginatorInfo>.
54
55=head1 RETURN VALUES
56
57CMS_add0_cert(), CMS_add1_cert() and CMS_add0_crl() and CMS_add1_crl() return
581 for success and 0 for failure.
59
60CMS_get1_certs() and CMS_get1_crls() return the STACK of certificates or CRLs,
61which is empty if there are none. They return NULL on error.
62Besides out-of-memory, the only error which will occur
63in practice is if the I<cms> type is invalid.
64
65=head1 SEE ALSO
66
67L<ERR_get_error(3)>,
68L<CMS_sign(3)>, L<CMS_sign_ex(3)>, L<CMS_verify(3)>,
69L<CMS_encrypt(3)>
70
71=head1 HISTORY
72
73CMS_add0_cert() and CMS_add1_cert() have been changed in OpenSSL 3.2
74not to throw an error if a certificate to be added is already present.
75
76=head1 COPYRIGHT
77
78Copyright 2008-2024 The OpenSSL Project Authors. All Rights Reserved.
79
80Licensed under the Apache License 2.0 (the "License").  You may not use
81this file except in compliance with the License.  You can obtain a copy
82in the file LICENSE in the source distribution or at
83L<https://www.openssl.org/source/license.html>.
84
85=cut
86