(Unicode C) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkCertW.h>
#include <C_CkPublicKeyW.h>
void ChilkatSample(void)
{
BOOL success;
HCkCertW cert;
const wchar_t *strPem;
HCkPublicKeyW pubKey;
success = FALSE;
cert = CkCertW_Create();
strPem = L"-----BEGIN CERTIFICATE----- ...";
success = CkCertW_LoadPem(cert,strPem);
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
pubKey = CkPublicKeyW_Create();
CkCertW_GetPublicKey(cert,pubKey);
// You can now use the public key object however it is needed,
// and access its various properties and methods..
wprintf(L"%s\n",CkPublicKeyW_getXml(pubKey));
CkCertW_Dispose(cert);
CkPublicKeyW_Dispose(pubKey);
}
|