(Unicode 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_CkCertW.h>
void ChilkatSample(void)
{
HCkCertW cert;
BOOL success;
cert = CkCertW_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 = CkCertW_LoadFromFile(cert,L"/Users/chilkat/testData/pem/chilkat.pem");
if (success != TRUE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
success = CkCertW_ExportCertDerFile(cert,L"chilkat.der");
if (success != TRUE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
wprintf(L"Converted certificate from PEM to DER format.\n");
CkCertW_Dispose(cert);
}
|