Skip to content
Guides

Verify Digital Certificates

When verifying digital certificates, the system automatically checks the trustworthiness of all certificates in the certificate chain and also verifies whether the certificates have expired. Only certificates that are both not expired and considered trustworthy in the entire certificate chain are considered trusted digital certificates.

This example shows how to verify digital certificates:

java
// Verify whether the specified certificate file is trusted.
// 
// To verify the trustworthiness of a certificate, you need to validate that all certificates in the certificate chain are trustworthy.
String certFilePath = rootDir+"/certificate/Certificate.pfx";
String password = "ComPDFKit";
if (CPDFSignature.checkPKCS12Password(certFilePath, password)) {
    CPDFX509 x509 = CPDFSignature.getX509ByPKCS12Cert(certFilePath, password);
    boolean isTrusted = x509.checkCertificateIsTrusted(rootDir + "/trusted");
    if (isTrusted) {
        // Certificate is trusted.
        System.out.println("certificate is in trusted list");
    } else {
        // Certificate is trusted.
        System.out.println("not in");
    }
}