CMS_add0_cert.pod 2.9 KB

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