CMS_add0_cert.3ossl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "CMS_ADD0_CERT 3ossl"
  58. .TH CMS_ADD0_CERT 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. CMS_add0_cert, CMS_add1_cert, CMS_get1_certs,
  65. CMS_add0_crl, CMS_add1_crl, CMS_get1_crls
  66. \&\- CMS certificate and CRL utility functions
  67. .SH SYNOPSIS
  68. .IX Header "SYNOPSIS"
  69. .Vb 1
  70. \& #include <openssl/cms.h>
  71. \&
  72. \& int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
  73. \& int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
  74. \& STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
  75. \&
  76. \& int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
  77. \& int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
  78. \& STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
  79. .Ve
  80. .SH DESCRIPTION
  81. .IX Header "DESCRIPTION"
  82. \&\fBCMS_add0_cert()\fR and \fBCMS_add1_cert()\fR add certificate \fIcert\fR to \fIcms\fR
  83. unless it is already present.
  84. This is used by \fBCMS_sign_ex\fR\|(3) and \fBCMS_sign\fR\|(3) and may be used before
  85. calling \fBCMS_verify\fR\|(3) to help chain building in certificate validation.
  86. As the 0 implies, \fBCMS_add0_cert()\fR adds \fIcert\fR internally to \fIcms\fR
  87. and on success it must not be freed up by the caller.
  88. In contrast, the caller of \fBCMS_add1_cert()\fR must free \fIcert\fR.
  89. \&\fIcms\fR must be of type signed data or (authenticated) enveloped data.
  90. For signed data, such a certificate can be used when signing or verifying
  91. to fill in the signer certificate or to provide an extra CA certificate
  92. that may be needed for chain building in certificate validation.
  93. .PP
  94. \&\fBCMS_get1_certs()\fR returns all certificates in \fIcms\fR.
  95. .PP
  96. \&\fBCMS_add0_crl()\fR and \fBCMS_add1_crl()\fR add CRL \fIcrl\fR to \fIcms\fR.
  97. \&\fIcms\fR must be of type signed data or (authenticated) enveloped data.
  98. For signed data, such a CRL may be used in certificate validation
  99. with \fBCMS_verify\fR\|(3).
  100. It may be given both for inclusion when signing a CMS message
  101. and when verifying a signed CMS message.
  102. .PP
  103. \&\fBCMS_get1_crls()\fR returns all CRLs in \fIcms\fR.
  104. .SH NOTES
  105. .IX Header "NOTES"
  106. The CMS_ContentInfo structure \fIcms\fR must be of type signed data or enveloped
  107. data or authenticated enveloped data or an error will be returned.
  108. .PP
  109. For signed data, certificates and CRLs are added to the \fIcertificates\fR and
  110. \&\fIcrls\fR fields of SignedData structure.
  111. For enveloped data they are added to \fBOriginatorInfo\fR.
  112. .SH "RETURN VALUES"
  113. .IX Header "RETURN VALUES"
  114. \&\fBCMS_add0_cert()\fR, \fBCMS_add1_cert()\fR and \fBCMS_add0_crl()\fR and \fBCMS_add1_crl()\fR return
  115. 1 for success and 0 for failure.
  116. .PP
  117. \&\fBCMS_get1_certs()\fR and \fBCMS_get1_crls()\fR return the STACK of certificates or CRLs,
  118. which is empty if there are none. They return NULL on error.
  119. Besides out-of-memory, the only error which will occur
  120. in practice is if the \fIcms\fR type is invalid.
  121. .SH "SEE ALSO"
  122. .IX Header "SEE ALSO"
  123. \&\fBERR_get_error\fR\|(3),
  124. \&\fBCMS_sign\fR\|(3), \fBCMS_sign_ex\fR\|(3), \fBCMS_verify\fR\|(3),
  125. \&\fBCMS_encrypt\fR\|(3)
  126. .SH HISTORY
  127. .IX Header "HISTORY"
  128. \&\fBCMS_add0_cert()\fR and \fBCMS_add1_cert()\fR have been changed in OpenSSL 3.2
  129. not to throw an error if a certificate to be added is already present.
  130. .SH COPYRIGHT
  131. .IX Header "COPYRIGHT"
  132. Copyright 2008\-2024 The OpenSSL Project Authors. All Rights Reserved.
  133. .PP
  134. Licensed under the Apache License 2.0 (the "License"). You may not use
  135. this file except in compliance with the License. You can obtain a copy
  136. in the file LICENSE in the source distribution or at
  137. <https://www.openssl.org/source/license.html>.