Sample code for 30+ languages & platforms
PureBasic

Get JSON Details from the Last PFX Operation

See more PFX/P12 Examples

Demonstrates Pfx.GetLastJsonData, which replaces the contents of a JsonObject with structured JSON information from the most recent operation.

The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.

Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.

Background. The data is copied as a complete replacement and is never merged with existing members. The exact members depend on the operation that produced them.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkPfx.pb"
IncludeFile "CkJsonObject.pb"

Procedure ChilkatExample()

    success.i = 0

    pfx.i = CkPfx::ckCreate()
    If pfx.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  The file path is relative to the application's current working directory.  An absolute path
    ;  may also be used.  Supply the path appropriate to your own environment.
    ;  The PFX password should come from a secure source rather than being hard-coded.
    password.s = "myPfxPassword"
    success = CkPfx::ckLoadPfxFile(pfx,"qa_data/identity.pfx",password)
    If success = 0
        Debug CkPfx::ckLastErrorText(pfx)
        CkPfx::ckDispose(pfx)
        ProcedureReturn
    EndIf

    ;  Copy structured JSON information from the most recent operation into a JsonObject.  The contents
    ;  entirely replace anything already in the object.
    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkPfx::ckGetLastJsonData(pfx,json)

    CkJsonObject::setCkEmitCompact(json, 0)
    jsonStr.s = CkJsonObject::ckEmit(json)
    Debug jsonStr
    ;  JSON parsing code for this result can be generated at Chilkat's online tool:
    ;  https://tools.chilkat.io/jsonParse


    CkPfx::ckDispose(pfx)
    CkJsonObject::ckDispose(json)


    ProcedureReturn
EndProcedure