| SMIME_WRITE_CMS(3) | Library Functions Manual | SMIME_WRITE_CMS(3) |
SMIME_write_CMS —
convert CMS structure to S/MIME format
library “libcrypto”
#include <openssl/cms.h>
int
SMIME_write_CMS(BIO *out,
CMS_ContentInfo *cms, BIO *data,
int flags);
SMIME_write_CMS()
generates an S/MIME message on out by writing MIME 1.0
headers followed by a BER- and base64-encoded serialization of
cms. The BER encoding uses the DER format except as
described for CMS_STREAM below. If streaming is
enabled, the content must be supplied in the data
argument.
The flags can be the logical OR of zero or more of the following bits:
CMS_DETACHEDNULL pointer, this
flag is ignored.
This flag is only supported if cms is of
the type SignedData and
CMS_DETACHED was also set when it was created
with CMS_sign(3).
If CMS_STREAM is not set, the data
must be read twice: once to compute the signature in
CMS_sign(3) and once to output the S/MIME message.
If CMS_DETACHED is ignored or not
specified, the smime-type is chosen according to
CMS_get0_type(3):
NID_pkcs7_envelopedNID_pkcs7_signedNID_id_smime_ct_receiptNID_id_smime_ct_compressedDataCMS_REUSE_DIGESTCMS_DETACHED is also set.CMS_STREAMCMS_DETACHED is not specified.
This flag should only be set if
CMS_STREAM was also passed to the function that
created cms.
The content is output in BER format using indefinite length constructed encoding except in the case of SignedData with detached content where the content is absent and DER format is used.
CMS_TEXTCMS_DETACHED is also set. It
is ignored if the flag SMIME_BINARY is also
set.SMIME_BINARYSMIME_CRLFEOLSMIME_write_CMS() is intended to return 1
on success or 0 on failure.
BIO_f_base64(3), BIO_new(3), CMS_ContentInfo_new(3), CMS_encrypt(3), CMS_sign(3), d2i_CMS_ContentInfo(3), ERR_get_error(3), SMIME_crlf_copy(3), SMIME_read_CMS(3), SMIME_write_PKCS7(3)
SMIME_write_CMS() first appeared in
OpenSSL 0.9.8h and has been available since OpenBSD
6.7.
SMIME_write_CMS() ignores most errors and
is likely to return 1 even after producing corrupt or incomplete output.
SMIME_write_CMS() always base64 encodes
CMS structures. There should be an option to disable this.
| June 11, 2025 | Debian |