(C) Convert Certificate from DER to PEM.
Loads a digital certificate from any format, such as DER, and saves to PEM format.
#include <C_CkCert.h>
void ChilkatSample(void)
{
HCkCert cert;
BOOL success;
cert = CkCert_Create();
// LoadFromFile will load virtually any certificate format file.
// It will auto-recognize the format and load appropiately.
// In this case, load a DER format certificate and convert to PEM.
success = CkCert_LoadFromFile(cert,"qa_data/certs/testCert.cer");
if (success != TRUE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkCert_Dispose(cert);
return;
}
success = CkCert_ExportCertPemFile(cert,"qa_data/certs/testCert.pem");
if (success != TRUE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkCert_Dispose(cert);
return;
}
printf("Converted certificate from DER to PEM format.\n");
CkCert_Dispose(cert);
}
|