Sample code for 30+ languages & platforms
Node.js

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var cert = new chilkat.Cert();

    success = cert.LoadFromFile("qa_data/pem/my_cert.pem");
    if (success == false) {
        console.log(cert.LastErrorText);
        return;
    }

    var pubkey = new chilkat.PublicKey();
    cert.GetPublicKey(pubkey);

    // Examine the public key as XML..
    console.log(pubkey.GetXml());

}

chilkatExample();