CkPhp Requires Chilkat v11.8.0+
CkPhp
Workaround for the deprecated Crypt2.AddPfxSourceData method
Shows how to replace the deprecated AddPfxSourceData method. (Chilkat is moving away from the use of CkByteData.) The replacement is AddPemSource, with the certificate and private key loaded from a PEM file.Chilkat CkPhp Downloads
<?php
include("chilkat.php");
$success = false;
$crypt = new CkCrypt2();
$path = 'c:/data/example.pfx';
$pfxPassword = 'secret';
// ------------------------------------------------------------------------
// The AddPfxSourceData method is deprecated:
$inData = new CkByteData();
$inData->loadFile($path);
$success = $crypt->AddPfxSourceData($inData,$pfxPassword);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData, and the AddPfxSource methods are deprecated.)
// Load the certificate and its private key from a PEM file into a Pem object, and call AddPemSource.
// The 2nd argument of LoadPemFile is the password of the private key.
// (Pass an empty string if the private key is not encrypted.)
$pem = new CkPem();
$success = $pem->LoadPemFile('c:/data/example.pem','secret');
$success = $crypt->AddPemSource($pem);
?>