SMIME_WRITE_CMS(3ossl)
β¨ SMIME_WRITE_CMS π
ok so bestie, meet SMIME_write_CMS β she's the one from the 3ossl manual fam whose whole job is turning a CMS structure into an actual S/MIME message. glow-up: applied. π
πΈ SYNOPSIS πΈ
#include <openssl/cms.h>
int SMIME_write_CMS(BIO *out, CMS_ContentInfo *cms, BIO *data, int flags);
π¦ DESCRIPTION π¦
okay so what she does is: she takes a CMS structure and slaps the appropriate MIME headers on top of it so it comes out looking like a real S/MIME message. it's giving β¨packaging queenβ¨.
Let's break down the cast:
outβ theBIOyou're writing the data to. that's the destination, the vibe.cmsβ theCMS_ContentInfostructure in question. the actual main character.dataβ if streaming is enabled, then the content must be supplied here. no content, no streaming, fr fr. πflagsβ an optional set of flags. optional bestie, but she's got range, keep reading.
π NOTES π
so these are the flags you can pass in that flags parameter. take notes bestie, this is the good part:
- If
CMS_DETACHEDis set, then cleartext signing will be used. lowkey this option only makes sense forSignedDatawhereCMS_DETACHEDis also set whenCMS_sign()is called. like, they have to match, iykyk. - If the
CMS_TEXTflag is set, MIME headers for typetext/plainget added to the content. but this only makes sense ifCMS_DETACHEDis also set. otherwise she's just doing too much. π - If the
CMS_STREAMflag is set, streaming is performed. important: this flag should only be set ifCMS_STREAMwas also set in the previous call to aCMS_ContentInfocreation function. they gotta be in sync, periodt. - 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 bestie, twice. she's thorough like that. π - 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. not me remembering both of these... but you should π«Ά
π BUGS π
ok this is the part where we keep it real:
SMIME_write_CMS() always base64 encodes CMS structures. there should be an option to disable this, but there isn't. so. yeah. that's the tea. π
π RETURN VALUES π
1for success β¨0for failure π
that's it, that's the range.
π SEE ALSO π
go read these next, bestie, they're all in the group chat:
π 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 babe π this lil slice of OpenSSL is version 3.5.9, dated 2026-09-29, and she ate. no cap. π«Άβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms