parsePfxDer
parsePfxDer
Decodes a BER- or DER-encoded PKCS#12/PFX container into its constituent bags.
The PFX, AuthenticatedSafe and SafeContents layers accept BER: indefinite and non-minimal lengths and constructed OCTET STRINGs. The MAC is verified over the AuthenticatedSafe octets as received. Certificates and private keys inside the bags must be DER.
Returns a result union — check ok before accessing value. Encrypted containers require options.password. MAC verification uses options.macPassword (falls back to options.password).
ts
function parsePfxDer(
der: Uint8Array,
options?: ParsePfxOptions,
): Promise<ParsePfxResult>Parameters
der:Uint8Arrayoptions?:ParsePfxOptions
Examples
ts
import { parsePfxDer } from 'micro509';
const result = await parsePfxDer(pfxBytes, { password: 's3cret' });
if (result.ok) {
console.log(result.value.certificates.length);
}