(Java) Example: Crypt2.SetSigningCert method
Demonstrates how to call the SetSigningCert method.
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[])
{
// Signing certificates can be obtained from many different sources..
// Load from a PFX
CkCrypt2 cryptA = new CkCrypt2();
CkCert certA = new CkCert();
boolean success = certA.LoadPfxFile("c:/someDir/pfx_files/a.pfx","pfx_file_password");
success = cryptA.SetSigningCert(certA);
// ...
// Load from a smart card or USB token.
CkCrypt2 cryptB = new CkCrypt2();
CkCert certB = new CkCert();
certB.put_SmartCardPin("123456");
success = certB.LoadFromSmartcard("");
success = cryptB.SetSigningCert(certB);
// ...
// Load from a the Windows certificate store or macOS keychain
CkCrypt2 cryptC = new CkCrypt2();
CkCert certC = new CkCert();
success = certC.LoadByCommonName("Xyz 123");
success = cryptC.SetSigningCert(certC);
// ...
}
}
|