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.
CPDFSignatureValidator provides document-level and field-level reports for signature integrity, coverage, document permissions, certificate chains, timestamps, and revocation materials. Existing boolean methods such as CPDFSignature.verify() remain available.
Here, document is the open signed output document. trustedCertPath is a PEM bundle of trusted roots or an OpenSSL-style certificate directory. Run validation on a background thread and keep the document open throughout the operation.
import com.compdfkit.core.signature.CPDFSignatureValidationOptions;
import com.compdfkit.core.signature.CPDFSignatureValidationResult;
import com.compdfkit.core.signature.CPDFSignatureValidationReport;
import com.compdfkit.core.signature.CPDFSignatureValidator;
CPDFSignatureValidationOptions options = new CPDFSignatureValidationOptions()
.setTrustedCertPath(trustedCertPath)
.setCheckTimestamp(true)
.setCheckRevocation(true);
CPDFSignatureValidationResult result = CPDFSignatureValidator.validate(document, options);
if (result != null && result.isSuccess()) {
for (CPDFSignatureValidationReport report : result.getReports()) {
String fieldName = report.getFieldName();
// Inspect report.getOverallStatus() and the checks in report.getItems().
}
} else {
// Validation did not execute successfully. Inspect errors and warnings if result is non-null.
}val options = CPDFSignatureValidationOptions()
.setTrustedCertPath(trustedCertPath)
.setCheckTimestamp(true)
.setCheckRevocation(true)
val result = CPDFSignatureValidator.validate(document, options)
if (result != null && result.isSuccess) {
for (report in result.reports) {
val fieldName = report.fieldName
// Inspect report.overallStatus and the checks in report.items.
}
} else {
// Handle execution failure and inspect errors and warnings.
}You can also call validate(pdfPath, options) for a file path, or use options.setFieldName(fieldName) to restrict validation to one field. An empty name validates all signatures.
For path-loaded documents, signature bytes are read from the file; Uri-loaded documents use their file access handle. Open and validate the actual signed output, rather than treating unsaved edits as the signed file.
| Check | Configuration method | Default |
|---|---|---|
| Signed-byte integrity | setCheckIntegrity() | true |
| ByteRange coverage | setCheckCoverage() | true |
| DocMDP/FieldMDP permissions for later revisions | setCheckDocumentPermissions() | true |
| Certificate chain | setCheckCertificateChain() | true |
| Timestamp | setCheckTimestamp() | true |
| Revocation and LTV | setCheckRevocation() | false |
Android provides no default OpenSSL trust store for this validator. Configure trusted certificates for chain and TSA trust checks. Enable setCheckRevocation(true) for LTV assessment; with it disabled, a false result from isLtvEnabled() does not prove that LTV materials are missing.
Validation reads OCSP/CRL evidence from the document's DSS and does not fetch missing materials online. See Long-Term Validation and PAdES Signing to add materials.
result.isSuccess() only indicates that validation executed successfully, not that every signature is valid. Check the report count, overall status, and individual checks:
CPDFValidationStatus | Meaning |
|---|---|
VALID | The relevant check passed |
INVALID | The relevant check failed |
INDETERMINATE | No definite conclusion, for example because trust anchors or materials are missing |
NOT_CHECKED | The check is disabled or not applicable |
report.getItems() provides individual checks. Use getCode(), getStatus(), and getMessage() to record reasons. result.getErrors() and getWarnings() provide run-level errors and warnings.
report.hasEmbeddedTimestamp() reads timestamp-related flags and does not establish timestamp trust on its own. report.isLtvEnabled() depends on the checks enabled; display it together with the complete signature report.