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

    Represents a SafeBag structure in a PKCS#12 file.

    A SafeBag is a container for different types of objects stored in PKCS#12 files, such as certificates, private keys, and CRLs. Each bag has a specific type (bagId) that determines how to interpret the bag's content (bagValue). Optional attributes can provide additional metadata like friendly names.

    SafeBag ::= SEQUENCE {
      bagId         BAG-TYPE,
      bagValue      [0] EXPLICIT ANY DEFINED BY bagId,
      bagAttributes SET OF PKCS12Attribute OPTIONAL
    }
    
    // Create a certificate bag
    const certBag = new SafeBag({
    bagId: OIDs.certBag,
    bagValue: new CertBag({
    certId: OIDs.x509Certificate,
    certValue: certificate.toDer()
    }),
    bagAttributes: [
    new Attribute({
    type: OIDs.friendlyName,
    values: ['My Certificate']
    })
    ]
    })

    // Create a private key bag
    const keyBag = new SafeBag({
    bagId: OIDs.pkcs8ShroudedKeyBag,
    bagValue: encryptedPrivateKeyInfo
    })

    // Extract content based on bag type
    if (safeBag.bagId.is(OIDs.certBag)) {
    const certBag = CertBag.fromAsn1(safeBag.bagValue.toAsn1())
    const certificate = certBag.extractCertificate()
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    bagAttributes?: Attribute[]

    Optional attributes providing metadata (e.g., friendly names, local key ID).

    Object identifier specifying the type of bag content. Common types include certBag, pkcs8ShroudedKeyBag, and keyBag.

    bagValue: Any

    The bag content, format determined by the bagId.

    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

      • type:
            | "KEY_BAG"
            | "PKCS8_SHROUDED_KEY_BAG"
            | "CERT_BAG"
            | "CRL_BAG"
            | "SECRET_BAG"
            | "SAFE_CONTENTS_BAG"

      Returns boolean

    • 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