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 <C_CkCertW.h>
#include <C_CkPublicKeyW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkCertW cert;
    HCkPublicKeyW pubkey;

    success = FALSE;

    cert = CkCertW_Create();

    success = CkCertW_LoadFromFile(cert,L"qa_data/pem/my_cert.pem");
    if (success == FALSE) {
        wprintf(L"%s\n",CkCertW_lastErrorText(cert));
        CkCertW_Dispose(cert);
        return;
    }

    pubkey = CkPublicKeyW_Create();
    CkCertW_GetPublicKey(cert,pubkey);

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


    CkCertW_Dispose(cert);
    CkPublicKeyW_Dispose(pubkey);

    }