(C) Convert to DER encoded X.509 Certificate (.cer, .crt)
Loads a digital certificate from any format and saves to a binary DER encoded X.509 Certificate (.cer, .crt).
#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 PEM format certificate and convert to DER.
success = CkCert_LoadFromFile(cert,"/Users/chilkat/testData/pem/chilkat.pem");
if (success != TRUE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkCert_Dispose(cert);
return;
}
success = CkCert_ExportCertDerFile(cert,"chilkat.der");
if (success != TRUE) {
printf("%s\n",CkCert_lastErrorText(cert));
CkCert_Dispose(cert);
return;
}
printf("Converted certificate from PEM to DER format.\n");
CkCert_Dispose(cert);
}
|