SMIME_READ_PKCS7(3ossl)
π SMIME_READ_PKCS7(3ossl) β or, "bestie reads her mail" β¨
okay so this is the OpenSSL manual page for SMIME_read_PKCS7_ex and SMIME_read_PKCS7, and it's literally about parsing S/MIME messages. no cap. if you've ever gotten an email with that little smime.p7s attachment and thought "what is this diva doing here" β that's this. let's get into it π
π NAME
SMIME_read_PKCS7_ex, SMIME_read_PKCS7 β parse S/MIME message
like. that's the whole job. she parses. she reads. she serves. π
β¨ SYNOPSIS
#include <openssl/pkcs7.h>
PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7);
PKCS7 *SMIME_read_PKCS7(BIO *in, BIO **bcont);
look at those signatures. immaculate. π«Ά
πΈ DESCRIPTION
so SMIME_read_PKCS7() parses a message that's in S/MIME format. that's it, that's the vibe.
in is a BIO β that's the thing you read the message from, bestie. it's giving "the mailbox" energy π¬
if cleartext signing is being used, then the content gets saved into a memory bio, and that memory bio gets written to *bcont. otherwise *bcont gets set to NULL. simple as that.
the parsed PKCS#7 structure is what comes back. or NULL if something went wrong π (we'll get to that).
now SMIME_read_PKCS7_ex() β she's the upgraded sister. she's similar to SMIME_read_PKCS7() but she can optionally take a previously created p7 PKCS#7 object. and if p7 is NULL, then honestly? she's identical to SMIME_read_PKCS7(). no difference, same girl, different font.
to create a p7 object, use PKCS7_new_ex(3). periodt. π
π NOTES
okay important stuff here, pay attention π§
if *bcont is not NULL, then that means the message is clear text signed. and then you can pass *bcont over to PKCS7_verify() with the PKCS7_DETACHED flag set. slay.
otherwise, you figure out the type of the returned structure using PKCS7_type_is_enveloped(), etc. she'll tell you what she is when she's ready π
and here's the little detail that matters β to support future functionality, if bcont is not NULL, then *bcont should be initialized to NULL. like, do it. for future you. for future us. for the girlies in the future π
for example:
BIO *cont = NULL;
PKCS7 *p7;
p7 = SMIME_read_PKCS7(in, &cont);
see? NULL. initialized. we love a prepared queen π
π BUGS
oop. okay. let's talk about it. π
the MIME parser that SMIME_read_PKCS7() uses is, and I quote, "somewhat primitive." she's not beating the allegations bestie. while it will handle most S/MIME messages, more complex compound formats may not work. so if your message is doing too much, she might just. not. π
also the parser assumes that the PKCS7 structure is always base64 encoded. so if it's in binary format, or if it's using quoted printable format? nope. not handled. she said "base64 or nothing" π
and here's the big one: using a memory BIO to hold the signed content limits the size of message which can be processed because of memory restraints. like, the whole thing has to fit in memory. the manpage literally says a streaming single pass option should be available β which is a very polite way of saying "we know, we know, it's on the list." π
π«Ά RETURN VALUES
SMIME_read_PKCS7_ex() and SMIME_read_PKCS7() return a valid PKCS7 structure, or NULL if an error occurred.
and if you got a NULL? the error can be obtained from ERR_get_error(3). go ask her what happened, she'll tell you π
π SEE ALSO
ERR_get_error(3)SMIME_read_PKCS7(3)PKCS7_sign(3)PKCS7_verify(3)PKCS7_encrypt(3)PKCS7_decrypt(3)
the whole friend group, fr fr π
π¦ HISTORY
the function SMIME_read_PKCS7_ex() was added in OpenSSL 3.0. so she's a newer girl on the block, and honestly? she ate. β¨
β COPYRIGHT
Copyright 2002-2020 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>.
(no I can't hyperlink it, it's a terminal bestie, go copy paste it π )
and that's the whole page!! this was SMIME_READ_PKCS7(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β mwah, iconic, no notes, go read your S/MIME messages responsibly πβ¨π
π¦ 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