Sample code for 30+ languages & platforms
Java

Example: Crypt2.SetDecryptCert2 method

Demonstrates how to call the SetDecryptCert2 method. This example loads the certificate and private key from PEM files:

PEM Format

Certificate file (cert.pem or cert.crt):

-----BEGIN CERTIFICATE-----
MIID... (base64-encoded data)
-----END CERTIFICATE-----

Private key file (key.pem or key.key):

-----BEGIN PRIVATE KEY-----
MIIE... (base64-encoded data)
-----END PRIVATE KEY-----

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Cert;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Crypt2;
import com.chilkatsoft.chilkat2.PrivateKey;

public class ChilkatExample {

    public static void main(String[] args) {
        Cert cert = new Cert();
        cert.loadFromFile("c:/certs_and_keys/certAbc.pem");
        // Assume success...

        PrivateKey privKey = new PrivateKey();
        privKey.loadAnyFormatFile("c:/certs_and_keys/certAbc_key.pem", "");
        // Assume success...

        Crypt2 crypt = new Crypt2();

        crypt.setCryptAlgorithm("pki");

        // ...
        // ...

        try {
            crypt.setDecryptCert2(cert, privKey);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Success.");
    }
}