CMS_VERIFY(3SSL)
π NAME π
okok so bestie, listen up β this page is all about verifying CMS stuff, fr fr. We got:
CMS_verify,CMS_SignedData_verify,CMS_get0_signers,CMS_SignerInfo_verify,CMS_SignerInfo_verify_content,CMS_SignerInfo_verify_exβ and what do they do? They verify CMS SignedData and SignedInfo structures. That's the whole vibe. π
β¨ SYNOPSIS β¨
#include <openssl/cms.h>
int CMS_verify(CMS_ContentInfo *cms, const 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,
const STACK_OF(X509) *scerts, X509_STORE *store,
const STACK_OF(X509) *extra,
const STACK_OF(X509_CRL) *crls,
unsigned int flags,
OSSL_LIB_CTX *libctx, const char *propq);
STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
int CMS_SignerInfo_verify(CMS_SignerInfo *si);
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);
int CMS_SignerInfo_verify_ex(CMS_SignerInfo *si, BIO *chain,
BIO *data);
πΈ DESCRIPTION πΈ
CMS_verify() is basically PKCS7_verify(3)'s cousin, lowkey the same energy. It verifies a CMS SignedData structure that's chillin inside a structure of type CMS_ContentInfo.
cmspoints at theCMS_ContentInfostructure we're verifying.- The optional
certsparameter is a set of certificates we search for signing certificates in. It's also used as a source of untrusted intermediate CA certificates for chain building. π cmsmay itself contain extra untrusted CA certificates that may be used for chain building, plus CRLs that may be used for certificate validation.storemay beNULL, or it points at the trusted certificate store to use for chain verification.detached_datarefers to the signed data if the content is detached fromcms. Otherwisedetached_datashould beNULLand the signed data must be insidecms.- The content gets written to the BIO
outunless it'sNULL. flagsis an optional set of flags, which can be used to modify the operation.
CMS_SignedData_verify() is like CMS_verify() except it operates on CMS SignedData input in the sd argument, it has some additional parameters (coming right up), and on success it returns the verified content as a memory BIO. π
- The optional
extraparameter 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. - The optional
crlsparameter may be used to provide extra CRLs. Also, the list of CRLs must not contain duplicates. - The optional parameters library context
libctxand property querypropqare used when retrieving algorithms from providers.
CMS_get0_signers() retrieves the signing certificate(s) from cms β and girlypop, it may only be called after a successful CMS_verify() or CMS_SignedData_verify() operation. No skipping ahead. π
CMS_SignerInfo_verify() verifies the signed attributes attached to the given SignerInfo si.
CMS_SignerInfo_verify_content() verifies the SignerInfo si part of a CMS_ContentInfo with the data provided by the cmsbio BIO. This BIO will be used by hash-based signing schemes and must return the same hash value as was produced by the cmsbio of CMS_dataFinal() or CMS_dataFinal_ex().
CMS_SignerInfo_verify_ex() extends CMS_SignerInfo_verify_content() with support for hash-less signing schemes, such as ML-DSA, SLH-DSA, or EdDSA, that require access to the raw (non-hashed) data. π₯ The raw data must be provided by the data BIO. Note that this BIO must support the seek() function so that its data stream can be read multiple times β once for each signature created by a hash-less signing scheme. Yeah, it re-reads. That's the point.
π¦ VERIFY PROCESS π¦
Normally the verify process goes like this, step by step, main character energy the whole way:
Initially some sanity checks are performed on cms. The type of cms must be SignedData. There must be at least one signature on the data, and if the content is detached, detached_data cannot be NULL.
An attempt is made to locate all the signing certificate(s): first by looking in the certs parameter (if it is not NULL), and then by looking in any certificates contained in the cms structure β unless CMS_NOINTERN is set. If any signing certificate cannot be located, the operation fails. π
Each signing certificate is chain verified using the smimesign purpose, and using the trusted certificate store store if 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 is NULL) and the signature is checked.
If all signatures verify correctly then the function is successful. slay. β¨
Any of the following flags (ored together) can be passed in the flags parameter to change the default verify behaviour:
- If
CMS_NOINTERNis set, the certificates in the message itself are not searched when locating the signing certificate(s). This means that all the signing certificates must be in thecertsparameter. - If
CMS_NOCRLis set and CRL checking is enabled instore, then any CRLs in the message itself and provided via thecrlsparameter are ignored. - If the
CMS_TEXTflag is set, 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. - If
CMS_NO_SIGNER_CERT_VERIFYis set, the signing certificates are not chain verified β unlessCMS_CADESflag is also set. - If
CMS_NO_ATTR_VERIFYis set, the signed attributes signature is not verified β unlessCMS_CADESflag is also set. - If
CMS_CADESis set, each signer certificate is checked against the ESSsigningCertificateor ESSsigningCertificateV2extension that is required in the signed attributes of the signature. - If
CMS_NO_CONTENT_VERIFYis set, then the content digest is not checked.
π 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.
In some cases the standard techniques for looking up and validating certificates are just not it: 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.
bestie, be careful when modifying the default verify behaviour, fr fr. For example, settingCMS_NO_CONTENT_VERIFYwill totally disable all content verification and any modified content will be considered valid. π This combination is however useful if one merely wishes to write the content tooutand its validity is not considered important.
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).
π 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).
π BUGS π (not the fun kind)
- The trusted certificate store is not searched for the signing certificate. This is primarily due to the inadequacies of the current
X509_STOREfunctionality. π - The lack of single pass processing means that the signed content must all be held in memory if it is not detached.
π 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)
β HISTORY β
CMS_SignedData_verify() was added in OpenSSL 3.2. β¨
π«Ά COPYRIGHT π«Ά
Copyright 2008-2026 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>.
and that's the whole page, bestie β this one's from OpenSSL 4.0.3, dated 2026-09-29, and it lives under the manual name CMS_VERIFY(3SSL). ily, go verify something π ππ¦
π¦ 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