Sample code for 30+ languages & platforms
PHP

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-----

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Cert;
use Chilkat2\Crypt2;
use Chilkat2\PrivateKey;

$cert = new Cert();
$cert->LoadFromFile('c:/certs_and_keys/certAbc.pem');
// Assume success...

$privKey = new PrivateKey();
$privKey->LoadAnyFormatFile('c:/certs_and_keys/certAbc_key.pem', '');
// Assume success...

$crypt = new Crypt2();

$crypt->CryptAlgorithm = 'pki';

// ...
// ...

try {
    $crypt->SetDecryptCert2($cert, $privKey);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

echo "Success.\n";