crypto.parsePKCS12(bundle[, options])


解析一个 PKCS#12 包,通常存储为 .p12 或 .pfx 扩展名,并返回它的私钥和证书。

🌐 Parses a PKCS#12 bundle, commonly stored with a .p12 or .pfx extension, and returns its private key and certificates.

import { parsePKCS12 } from 'node:crypto';
import { readFileSync } from 'node:fs';

const { privateKey, certificate, additionalCertificates } = parsePKCS12(
  readFileSync('bundle.p12'),
  { passphrase: 'secret' },
);