Sample code for 30+ languages & platforms
Unicode C++

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkCertW.h>
#include <CkPublicKeyW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCertW cert;

    success = cert.LoadFromFile(L"qa_data/certs/someCert.pem");
    if (success == false) {
        wprintf(L"%s\n",cert.lastErrorText());
        return;
    }

    // Get the certificate's public key:
    CkPublicKeyW pubkey;
    cert.GetPublicKey(pubkey);

    wprintf(L"%s\n",pubkey.getPem(false));

    // OK.. we have the public key which can be used in other Chilkat classes/methods...
    }