Sample code for 30+ languages & platforms
C++

Load PEM Format Certificate (.pem)

See more Certificates Examples

Loads a PEM format digital certificate and fetches information about the cert.

Chilkat C++ Downloads

C++
#include <CkCert.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCert cert;

    // LoadFromFile will load virtually any certificate format file.
    // It will auto-recognize the format and load appropiately.

    success = cert.LoadFromFile("/Users/chilkat/testData/cer/cert.pem");
    if (success != true) {
        std::cout << cert.lastErrorText() << "\r\n";
        return;
    }

    // DN = "Distinguished Name"
    std::cout << "SubjectDN:" << cert.subjectDN() << "\r\n";

    std::cout << "Common Name:" << cert.subjectCN() << "\r\n";
    std::cout << "Issuer Common Name:" << cert.issuerCN() << "\r\n";

    std::cout << "Serial Number:" << cert.serialNumber() << "\r\n";
    }