Sample code for 30+ languages & platforms
C++

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat C++ Downloads

C++
#include <CkCert.h>
#include <CkPublicKey.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCert cert;

    const char *strPem = "-----BEGIN CERTIFICATE----- ...";

    success = cert.LoadPem(strPem);
    if (success == false) {
        std::cout << cert.lastErrorText() << "\r\n";
        return;
    }

    CkPublicKey pubKey;
    cert.GetPublicKey(pubKey);

    //  You can now use the public key object however it is needed,
    //  and access its various properties and methods..

    std::cout << pubKey.getXml() << "\r\n";
    }