SMIME_WRITE_CMS(3SSL)
π SMIME_WRITE_CMS β the OpenSSL 3SSL manual, but make it make sense π
okay bestie, gather round, because today we're talking about SMIME_write_CMS, and she's from the OpenSSL family of manual pages, section 3SSL. literally the glow-up machine that takes your raw CMS structure and dresses it up all pretty in S/MIME format. periodt. π
β¨ NAME β¨
SMIME_write_CMS β convert CMS structure to S/MIME format
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
int SMIME_write_CMS(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags);
π¦ DESCRIPTION π¦
so here's the tea: SMIME_write_CMS() takes a CMS structure and slaps the appropriate MIME headers onto it, which is how you get a whole S/MIME message. it's giving "I woke up and chose formatting." π
out is the BIO where the data gets written to. cms is the relevant CMS_ContentInfo structure, aka the main character. and if streaming is enabled, you have to hand over the content in the data argument. flags is an optional set of flags β optional, but iconic. β¨
π NOTES π
you can pass the following flags in that flags parameter. buckle up, we're going one by one:
- if
CMS_DETACHEDis set, cleartext signing gets used. ngl this option only makes sense forSignedData, and only whenCMS_DETACHEDwas also set back whenCMS_sign()was called. they gotta match, fr fr. - if the
CMS_TEXTflag is set, MIME headers for typetext/plainget added to the content. again, this only makes sense ifCMS_DETACHEDis also set. them's the rules. - if the
CMS_STREAMflag is set, streaming is performed. super important: only set this ifCMS_STREAMwas also set in the previous call to aCMS_ContentInfocreation function. don't be out here setting flags alone, bestie. π«Ά - if cleartext signing is being used and
CMS_STREAMis not set, then the data must be read twice: once to compute the signature inCMS_sign(), and once to output the S/MIME message. yes, twice. it's giving cardio. π - if streaming is performed, the content is output in BER format using indefinite length constructed encoding β except in the case of signed data with detached content, where the content is absent and DER format is used instead. π§
π BUGS π
real talk: SMIME_write_CMS() always base64 encodes CMS structures. there should be an option to disable this, and there isn't. we live in a society. π
β RETURN VALUES β
SMIME_write_CMS() returns 1 for success or 0 for failure. simple as that. slay.
π SEE ALSO π
ERR_get_error(3), CMS_sign(3), CMS_verify(3), CMS_encrypt(3) CMS_decrypt(3)
π COPYRIGHT π
Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, bestie π«Ά this was version 4.0.3, dated 2026-09-29, straight from the SMIME_WRITE_CMS(3SSL) manual. go forth and MIME responsibly. mwah πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms