Java
Chilkat2 Java
Load PFX/P12 from a Base64 Encoded PFX File
See more PFX/P12 Examples
Demonstrates how to call LoadPfxEncoded.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.BinData;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Pfx;
public class ChilkatExample {
public static void main(String[] args) {
BinData bd = new BinData();
try {
bd.loadFile("qa_data/pfx/cert_test123.pfx");
} catch (ChilkatException e) {
System.out.println("Failed to load PFX file.");
return;
}
// Get the bytes contained in the PFX in base64 format:
String strBase64 = bd.getEncoded("base64");
// The base64 looks like this: "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
System.out.println(strBase64);
Pfx pfx = new Pfx();
// Load the PFX from the base64 string
String password = "test123";
try {
pfx.loadPfxEncoded(strBase64, "base64", password);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("success");
}
}