SMIME_READ_CMS(3ossl)
π SMIME_READ_CMS(3ossl) β like, the whole vibe
okay so bestie, welcome to the 3ossl corner of the OpenSSL man-verse π this one's all about SMIME_read_CMS_ex and SMIME_read_CMS, which is literally "parse S/MIME message" energy. yes. that's the name section. we ate. π
β¨ SYNOPSIS β¨
#include <openssl/cms.h>
CMS_ContentInfo *SMIME_read_CMS_ex(BIO *bio, int flags, BIO **bcont,
CMS_ContentInfo **cms);
CMS_ContentInfo *SMIME_read_CMS(BIO *in, BIO **bcont);
no cap, that's the whole signature situation π«Ά
π DESCRIPTION π
So SMIME_read_CMS() parses a message in S/MIME format. iconic behaviour honestly.
in is a BIO to read the message from. that's your source, your main character, your input stream β¨
If cleartext signing is used then the content is saved in a memory bio which is written to *bcont β otherwise *bcont is set to NULL. lowkey important detail, remember it πΈ
The parsed CMS_ContentInfo structure is returned, or NULL if an error occurred π (sad but honest).
Now for SMIME_read_CMS_ex() β she's similar to SMIME_read_CMS() but optionally a previously created cms CMS_ContentInfo object can be supplied as well as some flags. To create a cms object use CMS_ContentInfo_new_ex(3). iykyk π
- If the
flagsargument containsCMS_BINARYthen the input is assumed to be in binary format and is not translated to canonical form. π§ - If in addition
SMIME_ASCIICRLFis set then the binary input is assumed to be followed by CR and LF characters, else only by an LF character. π
And if flags is 0 and cms is NULL then it is identical to SMIME_read_CMS(). literally the same function, just wearing a different outfit π
π NOTES π
If *bcont is not NULL then the message is clear text signed. *bcont can then be passed to CMS_verify() with the CMS_DETACHED flag set. periodt. π₯
Otherwise the type of the returned structure can be determined using CMS_get0_type(). π¦
To support future functionality, ifbcontis notNULL,*bcontshould be initialized toNULL. bestie please do this, it's giving future-proofing π
For example:
BIO *cont = NULL;
CMS_ContentInfo *cms;
cms = SMIME_read_CMS(in, &cont);
that's it, that's the whole setup π
π BUGS π
okay so we gotta be honest, the MIME parser used by SMIME_read_CMS() is somewhat primitive. While it will handle most S/MIME messages, more complex compound formats may not work. it's trying its best π
The parser assumes that the CMS_ContentInfo structure is always base64 encoded, and will not handle the case where it is in binary format or uses quoted printable format. no cap, that's a real limitation β οΈ
The use of a memory BIO to hold the signed content limits the size of message which can be processed due to memory restraints: a streaming single pass option should be available. (future feature energy, we're manifesting it β¨)
π RETURN VALUES π
SMIME_read_CMS_ex() and SMIME_read_CMS() return a valid CMS_ContentInfo structure or NULL if an error occurred. The error can be obtained from ERR_get_error(3). so if it flops, that's where the receipts are π§Ύ
π SEE ALSO π
the whole crew, fr fr π
πΈ HISTORY πΈ
The function SMIME_read_CMS_ex() was added in OpenSSL 3.0. new-ish but already iconic β
Β©οΈ COPYRIGHT Β©οΈ
Copyright 2008-2021 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>. (yes, read the license bestie, it's not optional π
)
and that's the page!! mwah π this whole thing shipped with OpenSSL 3.5.0 and the date on it is 2026-09-25 β SMIME_read_CMS(3ossl), signing off π«Άβ¨ π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms