Sample code for 30+ languages & platforms
Java

Example: Crypt2.ClearSigningCerts method

Demonstrates how to call the ClearSigningCerts method.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.BinData;
import com.chilkatsoft.chilkat2.Cert;
import com.chilkatsoft.chilkat2.Crypt2;

public class ChilkatExample {

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

        Crypt2 crypt = new Crypt2();
        success = false;

        // Tell the crypt object to use 3 certificates.
        // Do this by calling AddSigningCert for each certificate.

        Cert cert1 = new Cert();
        // ...
        // Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
        // ...
        crypt.addSigningCert(cert1);

        Cert cert2 = new Cert();
        // ...
        crypt.addSigningCert(cert2);

        Cert cert3 = new Cert();
        // ...
        crypt.addSigningCert(cert3);

        BinData bd = new BinData();
        // ...

        crypt.opaqueSignBd(bd);

        // Let's say we now want to sign something else with different certs..
        // First clear the signing certs.
        crypt.clearSigningCerts();

        Cert cert4 = new Cert();
        // ...
        crypt.addSigningCert(cert4);

        Cert cert5 = new Cert();
        // ...
        crypt.addSigningCert(cert5);

        // ...
        // ...

        // Sign using cert4 and cert5.
        crypt.opaqueSignBd(bd);
    }
}