PHP
Chilkat2 PHP
Load PFX/P12 from a Base64 Encoded PFX File
See more PFX/P12 Examples
Demonstrates how to call LoadPfxEncoded.Chilkat PHP Downloads
<?php
use Chilkat2\BinData;
use Chilkat2\Pfx;
$bd = new BinData();
try {
$bd->LoadFile('qa_data/pfx/cert_test123.pfx');
} catch (\Chilkat2\Exception $e) {
echo "Failed to load PFX file.\n";
exit;
}
// Get the bytes contained in the PFX in base64 format:
$strBase64 = $bd->GetEncoded('base64');
// The base64 looks like this: "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
echo $strBase64, "\n";
$pfx = new Pfx();
// Load the PFX from the base64 string
$password = 'test123';
try {
$pfx->LoadPfxEncoded($strBase64, 'base64', $password);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo "success\n";