(Unicode C++) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
#include <CkCertW.h>
#include <CkPrivateKeyW.h>
void ChilkatSample(void)
{
// The LoadFromFile method will automatically detect the file format..
CkCertW cert;
bool 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");
}
|