CMS_GET0_SIGNERINFOS(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… CMS_GET0_SIGNERINFOS πŸ’…

ok so this is the 3ossl girlies' guide to the CMS signedData signer functions β€” CMS_SignerInfo_set1_signer_cert, CMS_get0_SignerInfos, CMS_SignerInfo_get0_signer_id, CMS_SignerInfo_get0_signature, and CMS_SignerInfo_cert_cmp. yes that's a lot of names, no we're not scared, let's go 🫢


✨ SYNOPSIS ✨

#include <openssl/cms.h>

STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);

int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, ASN1_OCTET_STRING **keyid,
                                  X509_NAME **issuer, ASN1_INTEGER **sno);
ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);
int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);

like, just look at it. iconic. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So CMS_get0_SignerInfos() hands you all the CMS_SignerInfo structures that are hanging out with a CMS signedData structure. the whole friend group. πŸ‘‘

CMS_SignerInfo_get0_signer_id() is the one that goes "ok who signed this" β€” it retrieves the certificate signer identifier for a specific CMS_SignerInfo structure si. And it's either/or, bestie: either the keyidentifier gets set in keyid, or both the issuer name and serial number get set in issuer and sno.

CMS_SignerInfo_get0_signature() grabs the signature linked to si, handed to you as a pointer to an ASN1_OCTET_STRING structure. and here's the slay part: that returned pointer is the internal signature value if si, so you can literally read it or modify it. main character pointer energy. ✨

CMS_SignerInfo_cert_cmp() compares the certificate cert against the signer identifier si. returns zero if the comparison is successful and non zero if not. simple as. πŸŽ€

CMS_SignerInfo_set1_signer_cert() sets the signers certificate of si to signer. boom, done.


🌸 NOTES 🌸

The whole point of these functions, like, the reason they exist: they let an application lookup signers certificates using any appropriate technique when the simpler method of CMS_verify() is not appropriate. sometimes the simple way just isn't the vibe. πŸ™ˆ

In typical usage an application will retrieve all CMS_SignerInfo structures using CMS_get0_SignerInfo() and retrieve the identifier information using CMS. then it obtains the signer certificate by some unspecified means (or returns an error if it cannot be found) and sets it using CMS_SignerInfo_set1_signer_cert(). iykyk. 🧚

Once all signer certificates have been set, CMS_verify() can be used. periodt. ⭐

ok so yes β€” CMS_get0_SignerInfos() can return NULL if an error occurs or if there are no signers. but ngl this is not a problem in practice, because the only error which can occur is if the cms structure is not of type signedData due to application error. so like… that's a you problem, bestie 😭

πŸ”₯ RETURN VALUES πŸ”₯

  • CMS_get0_SignerInfos() β€” returns all CMS_SignerInfo structures, or NULL if there are no signers or an error occurs.
  • CMS_SignerInfo_get0_signer_id() β€” returns 1 for success and 0 for failure.
  • CMS_SignerInfo_cert_cmp() β€” returns 0 for a successful comparison and non zero otherwise.
  • CMS_SignerInfo_set1_signer_cert() β€” does not return a value. it's giving void, it's giving no thoughts head empty πŸ’€

Any error can be obtained from ERR_get_error(3). go get that lore.


πŸ‘‘ SEE ALSO πŸ‘‘

ERR_get_error(3), CMS_verify(3)


Copyright 2008-2018 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>.


that's the whole page babes, certified slay, 3.5.0 and dated 2026-09-25 β€” go forth and verify those signers πŸ’œπŸŒˆ

πŸ“¦ where this page comes from