verifyPkcs7SignedData
verifyPkcs7SignedData
Verifies all signer signatures in a PKCS#7 SignedData structure.
Accepts PEM text, raw DER, or an already-parsed ParsedPkcs7SignedData. For each signer, locates the matching certificate in the embedded set and verifies the signature (including signed-attribute digest checks per RFC 5652 Section 5.4). Defaults to id-data and requires signed attributes on every signer. Select expectedContentTypeOid from the application's protocol, not the input envelope. Legacy bare id-data signatures require signedAttributes: 'allowed' or 'forbidden'. Non-id-data always requires attributes (RFC 5652 §5.3).
For a detached SignedData (absent eContent), pass the externally-held content via options.content; without it, verification fails with the typed detached_content_required code. When the SignedData embeds its own content, that embedded content is verified and options.content is ignored.
function verifyPkcs7SignedData(
input: string | Uint8Array | ParsedPkcs7SignedData,
options: VerifyPkcs7SignedDataOptions,
): Promise<VerifyPkcs7SignedDataResult>Parameters
input:string|Uint8Array|ParsedPkcs7SignedDataoptions:VerifyPkcs7SignedDataOptions
Examples
import { verifyPkcs7SignedData } from 'micro509';
const result = await verifyPkcs7SignedData(pkcs7Pem);
if (result.ok) {
for (const { signerInfo, certificate } of result.signers) {
console.log(signerInfo.digestAlgorithmOid, certificate.subject);
}
}
// Detached signature: supply the content externally
const detached = await verifyPkcs7SignedData(cmsBlob, { content: signedBytes });