(PHP Extension) Example: Crypt2.SetDecryptCert2 method
Demonstrates how to call the SetDecryptCert2 method. This example loads the certificate and private key from PEM files:
PEM Format
Certificate file (cert.pem or cert.crt ):
-----BEGIN CERTIFICATE-----
MIID... (base64-encoded data)
-----END CERTIFICATE-----
Private key file (key.pem or key.key ):
-----BEGIN PRIVATE KEY-----
MIIE... (base64-encoded data)
-----END PRIVATE KEY-----
<?php
include("chilkat.php");
$cert = new CkCert();
$success = $cert->LoadFromFile('c:/certs_and_keys/certAbc.pem');
// Assume success...
$privKey = new CkPrivateKey();
$success = $privKey->LoadAnyFormatFile('c:/certs_and_keys/certAbc_key.pem');
// Assume success...
$crypt = new CkCrypt2();
$crypt->put_CryptAlgorithm('pki');
// ...
// ...
$success = $crypt->SetDecryptCert2($cert,$privKey);
if ($success == false) {
print $crypt->lastErrorText() . "\n";
exit;
}
print 'Success.' . "\n";
?>
|