Sample code for 30+ languages & platforms
Node.js

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 Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var cert = new chilkat.Cert();
    success = cert.LoadFromFile("c:/certs_and_keys/certAbc.pem");
    //  Assume success...

    var privKey = new chilkat.PrivateKey();
    success = privKey.LoadAnyFormatFile("c:/certs_and_keys/certAbc_key.pem");
    //  Assume success...

    var crypt = new chilkat.Crypt2();

    crypt.CryptAlgorithm = "pki";

    //  ...
    //  ...

    success = crypt.SetDecryptCert2(cert,privKey);
    if (success == false) {
        console.log(crypt.LastErrorText);
        return;
    }

    console.log("Success.");

}

chilkatExample();