Unicode C
Unicode C
Transition from Cert.ExportPrivateKey to Cert.GetPrivateKey
Provides instructions for replacing deprecated ExportPrivateKey method calls with GetPrivateKey.Chilkat Unicode C Downloads
#include <C_CkCertW.h>
#include <C_CkPrivateKeyW.h>
void ChilkatSample(void)
{
BOOL success;
HCkCertW cert;
HCkPrivateKeyW privatekeyObj;
HCkPrivateKeyW privatekeyOut;
success = FALSE;
cert = CkCertW_Create();
// ------------------------------------------------------------------------
// The ExportPrivateKey method is deprecated:
privatekeyObj = CkCertW_ExportPrivateKey(cert);
if (CkCertW_getLastMethodSuccess(cert) == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
// ...
// ...
CkPrivateKeyW_Dispose(privatekeyObj);
// ------------------------------------------------------------------------
// Do the equivalent using GetPrivateKey.
// Your application creates a new, empty PrivateKey object which is passed
// in the last argument and filled upon success.
privatekeyOut = CkPrivateKeyW_Create();
success = CkCertW_GetPrivateKey(cert,privatekeyOut);
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
CkPrivateKeyW_Dispose(privatekeyOut);
return;
}
CkCertW_Dispose(cert);
CkPrivateKeyW_Dispose(privatekeyOut);
}