buildCandidatePath
buildCandidatePath
Builds a signature-verified path from a leaf certificate to a trusted root.
Parses the supplied certificates, walks the issuer chain, and returns the first path whose links pass. Each link checks the signature, the issuer's validity period, CA and keyCertSign constraints, path length, and key identifiers. validateCandidatePath checks the leaf's validity period, unrecognized critical extensions, certificate policies, name constraints, and leaf purpose. The all-in-one verifyCertificateChain also checks service identity and revocation.
ts
function buildCandidatePath(
input: BuildCandidatePathInput,
): Promise<BuildCandidatePathResult>Parameters
input:BuildCandidatePathInput
Examples
ts
import { buildCandidatePath } from 'micro509';
const result = await buildCandidatePath({
leaf: leafPem,
intermediates: [intermediatePem],
roots: [rootPem],
});
if (result.ok) {
console.log('path length:', result.value.chain.length);
}