Sample code for 30+ languages & platforms
PHP Extension

Load Certificate from .cer and Private Key from .pem

See more Certificates Examples

Load a certificate from a .cer and its associated private key from a .pem.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$cert = new CkCert();
$success = $cert->LoadFromFile('C:/certs_and_keys/Certificate.cer');
if ($success == false) {
    print $cert->lastErrorText() . "\n";
    exit;
}

$sbPem = new CkStringBuilder();
$success = $sbPem->LoadFile('C:/certs_and_keys/PrivateKey.pem','utf-8');
if ($success == false) {
    print 'Failed to load private key PEM' . "\n";
    exit;
}

$success = $cert->SetPrivateKeyPem($sbPem->getAsString());
if ($success == false) {
    print $cert->lastErrorText() . "\n";
    exit;
}

print 'The certificate and associated private key are now loaded and ready for signing.' . "\n";

?>