PKI-Lite - v1.2.1
    Preparing search index...

    Builder class for creating PKCS#12 (PFX) files.

    Provides a fluent API for assembling certificates and private keys into a password-protected PKCS#12 container. Uses PBES2 (PBKDF2 + AES-256-CBC) for encryption and HMAC-SHA-256 with PKCS#12 password-based key derivation (RFC 7292 Appendix B) for the MAC.

    const pfx = await PFX.builder()
    .addCertificate(clientCert)
    .addCertificate(caCert)
    .addPrivateKey(privateKey)
    .setPassword('s3cret')
    .setFriendlyName('My Identity')
    .build()

    const pem = pfx.toPem()

    Implements

    Index

    Constructors

    Methods

    • Sets an optional friendly name attached to the certificate/key bags.

      Parameters

      • friendlyName: string

        The friendly name

      Returns this

      This builder for chaining

    • Sets the number of iterations used by PBKDF2 and the MAC derivation. Defaults to 2048.

      Parameters

      • iterations: number

        Iteration count

      Returns this

      This builder for chaining

    • Sets the password used to encrypt the private keys and compute the MAC.

      Parameters

      • password: string | Uint8Array<ArrayBuffer>

        The password (string or bytes)

      Returns this

      This builder for chaining