SMIME_WRITE_PKCS7(3ossl)
π SMIME_write_PKCS7: the OpenSSL S/MIME glow-up π
okay so bestie, welcome to the SMIME_WRITE_PKCS7(3ossl) manual page from OpenSSL. This is the one where your PKCS#7 structure gets cute little MIME headers and becomes an S/MIME message. No cap, it's giving βmake it email-readyβ energy. π
π NAME π
SMIME_write_PKCS7 β convert PKCS#7 structure to S/MIME format.
β¨ SYNOPSIS β¨
#include <openssl/pkcs7.h>
int SMIME_write_PKCS7(BIO *out, PKCS7 *p7, BIO *data, int flags);
πΈ DESCRIPTION πΈ
SMIME_write_PKCS7() adds the appropriate MIME headers to a PKCS#7 structure to produce an S/MIME message. It's literally the glow-up step. β¨
outis the BIO to write the data to.p7is the appropriatePKCS7structure.- If streaming is enabled, then the content must be supplied in the
dataargument. flagsis an optional set of flags.
π NOTES π
The following flags can be passed in the flags parameter:
PKCS7_DETACHEDβ if this is set, cleartext signing will be used. This option only makes sense forsignedDatawherePKCS7_DETACHEDis also set whenPKCS7_sign()is also called.PKCS7_TEXTβ if this flag is set, MIME headers for typetext/plainare added to the content. This only makes sense ifPKCS7_DETACHEDis also set.PKCS7_STREAMβ if this flag is set, streaming is performed. This flag should only be set ifPKCS7_STREAMwas also set in the previous call toPKCS7_sign()orPKCS7_encrypt().
If cleartext signing is being used and PKCS7_STREAM is not set, then the data must be read twice: once to compute the signature in PKCS7_sign() and once to output the S/MIME message. Yes, twice. The data is doing 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.
π BUGS π
SMIME_write_PKCS7() always base64 encodes PKCS#7 structures. There should be an option to disable this. That's the known ick. π
π«Ά RETURN VALUES π«Ά
SMIME_write_PKCS7() returns 1 for success or 0 for failure.
π¦ SEE ALSO π¦
π COPYRIGHT π
Copyright 2002-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>.
mwah π β OpenSSL 3.5.0, dated 2026-09-25, signing off. Stay iconic, bestie. π
π¦ 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