Sample code for 30+ languages & platforms
Tcl

Load PFX/P12 from a Base64 Encoded PFX File

See more PFX/P12 Examples

Demonstrates how to call LoadPfxEncoded.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set bd [new_CkBinData]

set success [CkBinData_LoadFile $bd "qa_data/pfx/cert_test123.pfx"]
if {$success != 1} then {
    puts "Failed to load PFX file."
    delete_CkBinData $bd
    exit
}

# Get the bytes contained in the PFX in base64 format:
set strBase64 [CkBinData_getEncoded $bd "base64"]

# The base64 looks like this:  "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
puts "$strBase64"

set pfx [new_CkPfx]

# Load the PFX from the base64 string
set password "test123"
set success [CkPfx_LoadPfxEncoded $pfx $strBase64 "base64" $password]
if {$success != 1} then {
    puts [CkPfx_lastErrorText $pfx]
    delete_CkBinData $bd
    delete_CkPfx $pfx
    exit
}

puts "success"

delete_CkBinData $bd
delete_CkPfx $pfx