Java
Chilkat2 Java
Example: Crypt2.SetSigningCert2 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
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();
try {
crypt.setSigningCert2(cert, privKey);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Success.");
}
}