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

    Represents a PFX structure in a PKCS#12 file.

    PFX (Personal Information Exchange) is the main container format for PKCS#12 files. It can store private keys, certificates, and other cryptographic objects in a password-protected format. PKCS#12 files are commonly used for importing and exporting certificates and private keys between applications.

    PFX ::= SEQUENCE {
      version     INTEGER {v3(3)}(v3,...),
      authSafe    ContentInfo,
      macData     MacData OPTIONAL
    }
    
    // Load PKCS#12 file from PEM
    const p12Pem = '-----BEGIN PKCS12-----...-----END PKCS12-----'
    const pfx = PFX.fromPem(p12Pem)

    // Extract certificates and private keys
    const items = await pfx.extractItems('password123')
    const certificate = items.certificates[0]
    const privateKey = items.privateKeys[0]

    // Create new PKCS#12 file
    const newPfx = await PFX.create({
    certificates: [clientCert, caCert],
    privateKeys: [privateKey],
    password: 'newPassword',
    friendlyName: 'My Certificate'
    })

    // Save as PEM
    const pemData = newPfx.toPem()

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    authSafe: ContentInfo

    The authenticated safe containing the encrypted content.

    macData?: MacData

    Optional MAC data for integrity verification.

    version: number

    Version number (typically 3 for PKCS#12 v1.0).

    Accessors

    • get pemHeader(): string

      Gets the PEM header name for this object type. Converts the class name to uppercase for use in PEM encoding.

      Returns string

    • get pkiType(): string

      Gets the PKI type name for this object (typically the class name). Used for PEM headers and debugging output.

      Returns string

    Methods

    • Compares this PKI object with another for equality. Two objects are considered equal if their DER encodings are identical.

      Parameters

      • other: PkiBase<any>

        The other PKI object to compare with

      Returns boolean

      true if the objects are equal, false otherwise

    • Parameters

      • bagName:
            | "KEY_BAG"
            | "PKCS8_SHROUDED_KEY_BAG"
            | "CERT_BAG"
            | "CRL_BAG"
            | "SECRET_BAG"
            | "SAFE_CONTENTS_BAG"
      • password: string | Uint8Array<ArrayBufferLike>

      Returns Promise<SafeBag[]>

    • Returns a human-readable string representation of this object. By default, returns the same as toString(), but subclasses can override for more user-friendly output.

      Returns string

      A human-readable string representation

    • Creates a new PFX instance containing the given certificates and private keys.

      Parameters

      • options: {
            certificates: Certificate[];
            friendlyName?: string;
            password: string | Uint8Array<ArrayBufferLike>;
            privateKeys: PrivateKeyInfo[];
        }

        Configuration object

        • certificates: Certificate[]

          Array of certificates to include

        • OptionalfriendlyName?: string

          Optional friendly name for the key/cert pairs

        • password: string | Uint8Array<ArrayBufferLike>

          Password to encrypt the private keys

        • privateKeys: PrivateKeyInfo[]

          Array of private keys to include

      Returns Promise<PFX>

      A new PFX instance