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

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 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/pem/my_cert.pem");
    if (success == false) {
        wprintf(L"%s\n",cert.lastErrorText());
        return;
    }

    CkPublicKeyW pubkey;
    cert.GetPublicKey(pubkey);

    // Examine the public key as XML..
    wprintf(L"%s\n",pubkey.getXml());
    }