Unicode C++
Unicode C++
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat Unicode C++ Downloads
#include <CkCertW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
bool success = false;
CkCertW cert;
success = cert.LoadFromFile(L"C:/certs_and_keys/Certificate.cer");
if (success == false) {
wprintf(L"%s\n",cert.lastErrorText());
return;
}
CkStringBuilderW sbPem;
success = sbPem.LoadFile(L"C:/certs_and_keys/PrivateKey.pem",L"utf-8");
if (success == false) {
wprintf(L"Failed to load private key PEM\n");
return;
}
success = cert.SetPrivateKeyPem(sbPem.getAsString());
if (success == false) {
wprintf(L"%s\n",cert.lastErrorText());
return;
}
wprintf(L"The certificate and associated private key are now loaded and ready for signing.\n");
}