PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Trusting certificates involve two steps:
This example shows how to trust certificates:
// Add the certificate in the local storage as a trusted certificate.
String certFilePath = rootDir+"/certificate/Certificate.pfx";
String password = "ComPDFKit";
if (CPDFSignature.checkPKCS12Password(certFilePath, password)) {
CPDFX509 x509 = CPDFSignature.getX509ByPKCS12Cert(certFilePath, password);
// Add your certificate to the trust path.
boolean result = x509.addToTrustedCertificates(rootDir + "/trusted","compdfkit.pem");
if (result) {
System.out.println("add to trusted certificates success");
}else {
System.out.println("add to trusted certificates fail");
}
}
// Add digital signature certificate in pdf file as trusted certificate.
CPDFSignature signature = document.getPdfSignature(0);
CPDFSigner signer = signature.getSignerArr()[0];
CPDFX509 cpdfx509 = signer.getCert();
boolean result = cpdfx509.addToTrustedCertificates(rootDir + "/trusted","compdfkit.pem");
if (result) {
System.out.println("add to trusted certificates success");
}else {
System.out.println("add to trusted certificates fail");
}