PKCS7_SIGN_ADD_SIGNER(3SSL)
π NAME π
PKCS7_sign_add_signer, PKCS7_add_certificate, PKCS7_add_crl β okay bestie, these three are the little helpers that add info to a PKCS7 structure. Not the whole assemble-the-thing energy, just the β¨add stuffβ¨ energy. They live in the OpenSSL manual, section 3SSL, and honestly they're icons.
π SYNOPSIS π
#include <openssl/pkcs7.h>
PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, X509 *signcert,
EVP_PKEY *pkey, const EVP_MD *md, int flags);
int PKCS7_add_certificate(PKCS7 *p7, X509 *cert);
int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl);
πΈ DESCRIPTION πΈ
So PKCS7_sign_add_signer() is the main character here: it adds a signer to a PKCS7 signed data structure p7, using the certificate signcert, the private key pkey, and the message digest md. Three things in, one signer out, slay. π«Ά
Where does p7 come from tho? It should come from a first call to PKCS7_sign() where you set the PKCS7_PARTIAL flag β or from the case of re-signing a valid PKCS#7 signed data structure. iykyk. β¨
If md is NULL, then the default digest for the public key algorithm gets used instead. No stress.
And unless the PKCS7_REUSE_DIGEST flag is set, the PKCS7 structure you get back is not complete β it still has to be finalized, either by streaming (if that even applies to you) or by calling PKCS7_final(). Don't forget this part, fr fr, or your structure is just gonna be sitting there half-done. π
π NOTES π
Okay so the whole point of this function is finer control over a PKCS#7 signed data structure for when the simpler PKCS7_sign() function defaults just aren't giving what you need. Like, multiple signers? Non-default digest algorithms? Yeah, that's this function's moment. π
You can pass any of these flags ored together in the flags parameter:
- If
PKCS7_REUSE_DIGESTis set, it tries to copy the content digest value from thePKCS7structure β this is how you add a signer to an existing structure. If a matching digest value can't be found to copy, that's an error. When this flag is set, thePKCS7structure you get back will be valid and finalized. β - If
PKCS7_PARTIALis set in addition toPKCS7_REUSE_DIGEST, then thePKCS7_SIGNER_INOstructure will not be finalized, so you can add extra attributes to it. In that case you need an explicit call toPKCS7_SIGNER_INFO_sign()to finalize it. No skipping that step bestie. - If
PKCS7_NOCERTSis set, the signer's certificate will not be included in thePKCS7structure β but you still have to supply the signer's certificate in thesigncertparameter anyway. It can shrink the signature size if the signer's cert can be obtained some other way, like from a previously signed message. Work smarter π§ - The
signedDatastructure includes several PKCS#7authenticatedAttributes, including the signing time, the PKCS#7 content type, and the supported list of ciphers in anSMIMECapabilitiesattribute. IfPKCS7_NOATTRis set, then noauthenticatedAttributesget used at all. IfPKCS7_NOSMIMECAPis set, then just theSMIMECapabilitiesare omitted. - If it's there, the
SMIMECapabilitiesattribute indicates support for these algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. And if any of these algorithms is disabled, it won't be included. Simple as that. β¨
PKCS7_sign_add_signers() returns an internal pointer to the PKCS7_SIGNER_INFO structure that was just added β you can use it to set extra attributes before it gets finalized. Handy.
Then we have PKCS7_add_certificate(), which adds the certificate cert to the PKCS7 structure p7. That cert can be an end-entity (signer) certificate or a CA certificate useful for chain building. This is done internally by PKCS7_sign_ex(3) and all the similar signing functions. You might have to use it before calling PKCS7_verify(3) to provide any missing certificate(s) needed for verification. π
And PKCS7_add_crl() adds the CRL crl to the PKCS7 structure p7. You can call this to provide certificate status information to be included when signing, or to use it when verifying the PKCS7 structure.
π RETURN VALUES π
PKCS7_sign_add_signers() returns an internal pointer to the PKCS7_SIGNER_INFO structure that was just added, or NULL if an error happens. π
PKCS7_add_certificate() and PKCS7_add_crl() return 1 on success, 0 on error. That's it, that's the vibe check.
π¦ SEE ALSO π¦
ERR_get_error(3), PKCS7_sign_ex(3), PKCS7_final(3), PKCS7_verify(3)
π HISTORY π
The PPKCS7_sign_add_signer() function was added in OpenSSL 1.0.0. Iconic behavior since day one, honestly.
π COPYRIGHT π
Copyright 2007-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>.
π aaaand that's the whole page bestie β no cap, you now know this manpage better than the back of your hand. go forth and add signers responsibly πβ¨
version 4.0.3 Β· dated 2026-09-29 Β· OpenSSL, obviously π
π¦ 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