Sample code for 30+ languages & platforms
Java

Transition from Email.GetSignedByCertChain to Email.LastSignerCert

Provides instructions for replacing deprecated GetSignedByCertChain method calls with LastSignerCert.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkEmail email = new CkEmail();

    //  ...
    //  ...

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

    CkCertChain certChainObj = email.GetSignedByCertChain();
    if (email.get_LastMethodSuccess() == false) {
        System.out.println(email.lastErrorText());
        return;
        }

    //  ...
    //  ...

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

    CkCert signerCert = new CkCert();
    success = email.LastSignerCert(0,signerCert);
    if (success == false) {
        System.out.println(email.lastErrorText());
        return;
        }

    //  Get the certificate chain from the signer certificate.
    CkCertChain certChain = new CkCertChain();
    success = signerCert.BuildCertChain(certChain);
    if (success == false) {
        System.out.println(signerCert.lastErrorText());
        return;
        }
  }
}