Sample code for 30+ languages & platforms
Unicode C

Transition from Email.GetSignedByCertChain to Email.LastSignerCert

Provides instructions for replacing deprecated GetSignedByCertChain method calls with LastSignerCert.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkEmailW.h>
#include <C_CkCertChainW.h>
#include <C_CkCertW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkEmailW email;
    HCkCertChainW certChainObj;
    HCkCertW signerCert;
    HCkCertChainW certChain;

    success = FALSE;

    email = CkEmailW_Create();

    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  The GetSignedByCertChain method is deprecated:

    certChainObj = CkEmailW_GetSignedByCertChain(email);
    if (CkEmailW_getLastMethodSuccess(email) == FALSE) {
        wprintf(L"%s\n",CkEmailW_lastErrorText(email));
        CkEmailW_Dispose(email);
        return;
    }

    //  ...
    //  ...

    CkCertChainW_Dispose(certChainObj);

    //  ------------------------------------------------------------------------
    //  Do the equivalent using LastSignerCert to get the signing certificate,
    //  then build the cert chain from the signing certificate object.

    signerCert = CkCertW_Create();
    success = CkEmailW_LastSignerCert(email,0,signerCert);
    if (success == FALSE) {
        wprintf(L"%s\n",CkEmailW_lastErrorText(email));
        CkEmailW_Dispose(email);
        CkCertW_Dispose(signerCert);
        return;
    }

    //  Get the certificate chain from the signer certificate.
    certChain = CkCertChainW_Create();
    success = CkCertW_BuildCertChain(signerCert,certChain);
    if (success == FALSE) {
        wprintf(L"%s\n",CkCertW_lastErrorText(signerCert));
        CkEmailW_Dispose(email);
        CkCertW_Dispose(signerCert);
        CkCertChainW_Dispose(certChain);
        return;
    }



    CkEmailW_Dispose(email);
    CkCertW_Dispose(signerCert);
    CkCertChainW_Dispose(certChain);

    }