C
C
Transition from Email.GetSignedByCertChain to Email.LastSignerCert
Provides instructions for replacing deprecated GetSignedByCertChain method calls with LastSignerCert.Chilkat C Downloads
#include <C_CkEmail.h>
#include <C_CkCertChain.h>
#include <C_CkCert.h>
void ChilkatSample(void)
{
BOOL success;
HCkEmail email;
HCkCertChain certChainObj;
HCkCert signerCert;
HCkCertChain certChain;
success = FALSE;
email = CkEmail_Create();
// ...
// ...
// ------------------------------------------------------------------------
// The GetSignedByCertChain method is deprecated:
certChainObj = CkEmail_GetSignedByCertChain(email);
if (CkEmail_getLastMethodSuccess(email) == FALSE) {
printf("%s\n",CkEmail_lastErrorText(email));
CkEmail_Dispose(email);
return;
}
// ...
// ...
CkCertChain_Dispose(certChainObj);
// ------------------------------------------------------------------------
// Do the equivalent using LastSignerCert to get the signing certificate,
// then build the cert chain from the signing certificate object.
signerCert = CkCert_Create();
success = CkEmail_LastSignerCert(email,0,signerCert);
if (success == FALSE) {
printf("%s\n",CkEmail_lastErrorText(email));
CkEmail_Dispose(email);
CkCert_Dispose(signerCert);
return;
}
// Get the certificate chain from the signer certificate.
certChain = CkCertChain_Create();
success = CkCert_BuildCertChain(signerCert,certChain);
if (success == FALSE) {
printf("%s\n",CkCert_lastErrorText(signerCert));
CkEmail_Dispose(email);
CkCert_Dispose(signerCert);
CkCertChain_Dispose(certChain);
return;
}
CkEmail_Dispose(email);
CkCert_Dispose(signerCert);
CkCertChain_Dispose(certChain);
}