CMS_VERIFY(3ossl)
π CMS_VERIFY (3ossl) β the OpenSSL one, bestie
okay so this is the 3ossl man page for verifying CMS SignedData structures, and honestly? it's a whole vibe. three functions, one mission: making sure nobody messed with your signed content. let's get into it π
β¨ NAME β¨
CMS_verify, CMS_SignedData_verify, CMS_get0_signers β verify a CMS SignedData structure. that's it, that's the whole job, and they ate π
π¦ SYNOPSIS π¦
#include <openssl/cms.h>
int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store,
BIO *detached_data, BIO *out, unsigned int flags);
BIO *CMS_SignedData_verify(CMS_SignedData *sd, BIO *detached_data,
STACK_OF(X509) *scerts, X509_STORE *store,
STACK_OF(X509) *extra, STACK_OF(X509_CRL) *crls,
unsigned int flags,
OSSL_LIB_CTX *libctx, const char *propq);
STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
look at those signatures. main character energy, no cap β¨
πΈ DESCRIPTION πΈ
CMS_verify() π
this one is very similar to PKCS7_verify(3) β like, spiritually. it verifies a CMS SignedData structure sitting inside a structure of type CMS_ContentInfo.
cmsβ points to theCMS_ContentInfostructure you wanna verify. this is the thing.certsβ optional set of certificates to search for signing certificates in. it also does double duty as a source of untrusted intermediate CA certificates for chain building π«Άcmsitself may contain extra untrusted CA certificates that can be used for chain building, plus CRLs that may be used for certificate validation.storeβ may beNULL, or point to the trusted certificate store to use for chain verification.detached_dataβ refers to the signed data if the content is detached fromcms. if it's not detached,detached_datashould beNULLand the signed data has to live insidecms.outβ the content gets written to thisBIO, unless it'sNULL.flagsβ optional set of flags, used to modify the operation. more on those below π
CMS_SignedData_verify() β
like CMS_verify() but it operates on CMS SignedData input in the sd argument, it has some additional parameters (described next), and β plot twist β on success it returns the verified content as a memory BIO π₯
extraβ optional, may be used to provide untrusted CA certificates that may be helpful for chain building in certificate validation. this list of certificates must not contain duplicates. periodt.crlsβ optional, may be used to provide extra CRLs. also, the list of CRLs must not contain duplicates. i said what i said πlibctxandpropqβ optional library context and property query, used when retrieving algorithms from providers. provider stuff, iykyk β¨
CMS_get0_signers() π
retrieves the signing certificate(s) from cms. and listen β it may only be called after a successful CMS_verify() or CMS_SignedData_verify() operation. no skipping ahead, bestie π
π VERIFY PROCESS π
normally the verify process proceeds as follows. it's giving⦠a whole routine.
initially some sanity checks are performed on cms:
- the type of
cmsmust be SignedData. - there must be at least one signature on the data.
- if the content is detached,
detached_datacannot beNULL.
then an attempt is made to locate all the signing certificate(s), first looking in the certs parameter (if it's not NULL) and then looking in any certificates contained in the cms structure β unless CMS_NOINTERN is set. if any signing certificate cannot be located, the operation fails. sorry, them's the rules π
each signing certificate gets chain verified using the smimesign purpose, and using the trusted certificate store store if it was supplied. any internal certificates in the message β which may have been added using CMS_add1_cert(3) β are used as untrusted CAs. if CRL checking is enabled in store and CMS_NOCRL is not set, any internal CRLs (which may have been added using CMS_add1_crl(3)) are used, in addition to attempting to look them up in store. if store is not NULL and any chain verify fails, an error code is returned.
finally, the signed content is read (and written to out unless it's NULL) and the signature is checked. if all signatures verify correctly, then the function is successful. slay π
π© the flags, ranked by how much you should care π©
any of the following flags (ored together) can be passed in the flags parameter to change the default verify behaviour:
CMS_NOINTERNβ the certificates inside the message itself are not searched when locating the signing certificate(s). meaning: all the signing certificates must be in thecertsparameter. no exceptions πCMS_NOCRLβ if CRL checking is enabled instore, then any CRLs in the message itself and any provided via thecrlsparameter are ignored. bye felicia π¦CMS_TEXTβ MIME headers for type"text/plain"are deleted from the content. if the content is not of type"text/plain", then an error is returned. read the room, content.CMS_NO_SIGNER_CERT_VERIFYβ the signing certificates are not chain verifiedβ¦ unlessCMS_CADESis also set. sneaky little conditional.CMS_NO_ATTR_VERIFYβ the signed attributes signature is not verifiedβ¦ unlessCMS_CADESis also set. again with the "unless" π€CMS_CADESβ each signer certificate is checked against the ESSsigningCertificateor ESSsigningCertificateV2extension that is required in the signed attributes of the signature. fancy β¨CMS_NO_CONTENT_VERIFYβ the content digest is not checked. do not just casually turn this on, we'll get to why π
π NOTES π
one application of CMS_NOINTERN is to only accept messages signed by a small number of certificates. the acceptable certificates would be passed in the certs parameter. in this case, if the signer certificate is not one of the certificates supplied in certs, then the verify will fail because the signer cannot be found. that's the whole point, bestie π―
in some cases the standard techniques for looking up and validating certificates are not appropriate: for example, an application may wish to look up certificates in a database or perform customised verification. this can be achieved by setting and verifying the signer certificates manually using the signed data utility functions. DIY era π οΈ
β οΈ care should be taken when modifying the default verify behaviour. for example, setting CMS_NO_CONTENT_VERIFY will totally disable all content verification and any modified content will be considered valid. like, any content. anything. π¨
that combination is however useful if one merely wishes to write the content to out and its validity is not considered important. soβ¦ valid use case, terrifying flag. both things can be true π
chain verification should arguably be performed using the signing time rather than the current time. however, since the signing time is supplied by the signer, it cannot be trusted without additional evidence (such as a trusted timestamp). sad but true π
β RETURN VALUES β
CMS_verify()β returns1for a successful verification and0if an error occurred.CMS_SignedData_verify()β returns a memory BIO containing the verified content, orNULLon error.CMS_get0_signers()β returns all signers, orNULLif an error occurred.
the error can be obtained from ERR_get_error(3). go get your error, queen π
π BUGS π
- the trusted certificate store is not searched for the signing certificate. this is primarily due to the inadequacies of the current
X509_STOREfunctionality. not us, not our fault, pointing respectfully atX509_STOREπ - the lack of single pass processing means that the signed content must all be held in memory if it is not detached. hope you have RAM, bestie π
π SEE ALSO π
PKCS7_verify(3)CMS_add1_cert(3)CMS_add1_crl(3)OSSL_ESS_check_signing_certs(3)ERR_get_error(3)CMS_sign(3)
read them, they're all linked and they all matter π«Ά
π HISTORY π
CMS_SignedData_verify() was added in OpenSSL 3.2. new-ish function, fresh out the box β¨
π COPYRIGHT π
Copyright 2008-2024 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>.
okay that's the whole thing, go verify something π this page is from OpenSSL 3.5.6, dated 2026-04-07, and it's the CMS_VERIFY(3ossl) page β mwah, mwah, bye bestie ππ§π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms