# How to fix an invalid or expired PDF digital signature

Source: https://pdfluent.com/errors/pdf-signature-invalid/

Signature validation fails if the certificate expired, trust chain broke, PDF changed after signing, or hash differs. The page covers fixes in Rust.

Signature Validation Error

`PDF signature is invalid or certificate has expired`

## Why this happens

### Signing certificate has expired

X.509 certificates used to sign PDFs have an explicit validity period (notBefore / notAfter). Once expired, validators reject the signature as untrusted. Many organisations sign PDFs with short-lived certificates without enabling long-term validation (LTV), so the signature becomes invalid over time.

### Chain of trust is broken or root CA is not trusted

A PDF signature is only valid if the full certificate chain — from the signing certificate up through any intermediate CAs to a trusted root — can be verified. If an intermediate certificate is missing from the signature, or if the root CA is not in the verifier's trust store, validation fails.

### PDF modified after signing

A digital signature covers a specific byte range of the PDF. If any byte outside the signed range changes after signing (incremental updates, appended pages, metadata changes), the hash no longer matches and the signature is reported as invalid. This is by design — it is the core security guarantee of PDF signatures.

## How to fix it

1. Check certificate validity datesBefore trusting a signature, verify that the certificate was valid at the time of signing (not just today). PDFluent returns the signing time from the signature dictionary and checks it against the certificate validity window. code `*use pdfluent::PdfDocument;**let doc = PdfDocument::open("signed.pdf")?;**for sig in doc.signatures() {**let sig = sig?;**println!("PdfSigner: {}", sig.subject_dn());**println!("Signed at: {}", sig.signing_time());**println!("Cert valid from: {}", sig.cert_not_before());**println!("Cert valid until: {}", sig.cert_not_after());**println!("Signature covers full document: {}", sig.covers_whole_file());**}*`
2. Verify the full certificate chainTo validate the chain of trust, PDFluent needs access to the root CAs and any intermediate certificates. You can provide a custom trust store or use the system trust store. If a certificate in the chain is missing, PDFluent reports which one is absent. code `*let doc = PdfDocument::open("signed.pdf")?;**let report = doc.verify_signatures()?;**for validation in report.validations() {**match &validation.status {**SignatureStatus::Valid => println!("Signature is valid"),**SignatureStatus::Invalid { reason } => println!("Signature is invalid: {}", reason),**SignatureStatus::Unknown { reason } => println!("Signature status is unknown: {}", reason),**}**}*`
3. Ensure PDF is not modified after signingTo confirm a signature covers the full document, check that the signed byte range includes all content up to the end of file. If the document has been modified post-signing, PDFluent reports the byte ranges that are outside the signature coverage. code `*use pdfluent::PdfDocument;**let doc = PdfDocument::open("signed.pdf")?;**for sig in doc.signatures() {**let sig = sig?;**if!sig.covers_whole_file() {**eprintln!(**"Warning: signature does not cover the full document. {} bytes are outside the signed range.",**sig.unsigned_byte_count()**);**}**}*`

## Frequently asked questions

How do I check why a PDF signature is invalid?

Use PDFluent's sig.validate() method which returns a ValidationResult with a list of specific errors: certificate expiry, broken chain, hash mismatch, or unsigned content. Each error includes the certificate subject and the specific validation step that failed.

What makes a PDF digital signature valid?

A valid PDF signature requires: (1) the signed byte range matches the file content, (2) the signing certificate was valid at signing time, (3) the full certificate chain leads to a trusted root CA, and (4) the hash algorithm used is not deprecated (SHA-1 signatures are rejected by modern validators).

How do I verify a PDF signature in Rust?

Open the document with PDFluent, iterate doc.signatures(), and call sig.validate(&trust_store) on each. PDFluent handles PKCS#7 / CMS validation internally, including chain building and revocation checking via OCSP and CRL if network access is available.

## Related guides

[Fix: corrupt PDF parse error](https://pdfluent.com/errors/corrupt-pdf/)

Read the docs
