Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
set pfx [new_CkPfx]
# 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.
set password "myPfxPassword"
set success [CkPfx_LoadPfxFile $pfx "qa_data/identity.pfx" $password]
if {$success == 0} then {
puts [CkPfx_lastErrorText $pfx]
delete_CkPfx $pfx
exit
}
# Copy structured JSON information from the most recent operation into a JsonObject. The contents
# entirely replace anything already in the object.
set json [new_CkJsonObject]
CkPfx_GetLastJsonData $pfx $json
CkJsonObject_put_EmitCompact $json 0
set jsonStr [CkJsonObject_emit $json]
puts "$jsonStr"
# JSON parsing code for this result can be generated at Chilkat's online tool:
# https://tools.chilkat.io/jsonParse
delete_CkPfx $pfx
delete_CkJsonObject $json