Unicode C++
Unicode C++
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat Unicode C++ Downloads
#include <CkCertW.h>
#include <CkPrivateKeyW.h>
void ChilkatSample(void)
{
bool success = false;
// The LoadFromFile method will automatically detect the file format..
CkCertW cert;
success = cert.LoadFromFile(L"qa_data/zatca/cert.pem");
if (success != true) {
wprintf(L"%s\n",cert.lastErrorText());
return;
}
wprintf(L"%s\n",cert.subjectCN());
// Load the private key.
CkPrivateKeyW privKey;
success = privKey.LoadPemFile(L"qa_data/zatca/ec-secp256k1-priv-key.pem");
if (success != true) {
wprintf(L"%s\n",privKey.lastErrorText());
return;
}
wprintf(L"Key Type: %s\n",privKey.keyType());
// Associate the private key with the certificate.
success = cert.SetPrivateKey(privKey);
if (success != true) {
wprintf(L"%s\n",cert.lastErrorText());
return;
}
wprintf(L"Success.\n");
}