Fix PDF Signature Invalid Certificate and Document Corrupted Error
Question details
User encounters invalid certificate and document corrupted errors in a PDF reader after successfully signing a PDF with a third-party signature plug-in.

- Product
- PDF Reader
- Device & OS
- not provided
- Scenario
- Signing a PDF using a third-party plug-in that utilizes PubSec callbacks for authentication and digest calculation.
- Observed behavior
- The signature completes successfully via the plug-in, but the PDF reader subsequently flags the certificate as invalid and reports the document as corrupted.
Ensure you have the latest API documentation for your specific third-party signature plug-in and confirm your PDF reader is updated to avoid version compatibility issues.
Correct the Digest Calculation and Byte Range
Ensure the SHA-256 document digest exactly matches the final byte range and data buffer provided by the signature process.
The most common cause of document corruption and invalid certificate errors after signing is a mismatch between the calculated digest and the actual file content. The authentication callback in the plug-in might occur before the final signature contents and byte range are fully generated.
Check your plug-in's code to understand exactly when authentication and signature-value callbacks are triggered during the signing process.
Ensure the digest used for signing is calculated solely from the exact byte range and data buffer finalized by the signature process. Do not use premature calculations from the authentication callback.
Confirm that the digital signature is being applied as a strict incremental update to the PDF, ensuring previous file revisions are not altered or overwritten.

Validate the Certificate Chain and Signature Encoding
Fix potential issues related to incomplete trust chains or incorrect encoding formats in the signature plug-in.
Easily Sign PDFs Securely with WPS Office
Avoid complex third-party plug-in errors by using the built-in digital signature and document protection tools in WPS Office. Ensure your document integrity and certificate validity without technical hassles.
- 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to sign.
- 2. Navigate to the Protect tab: Click on the 'Protect' tab located on the top ribbon menu to access security features.
- 3. Sign the document: Click on 'Sign Document', choose or create your verified digital ID, and place the signature securely on the page.
- 4. Save the file: Save your PDF. WPS Office automatically handles the correct byte range and digest calculations to prevent corruption errors.

Frequently Asked Questions
Why does my PDF reader say my signed PDF is corrupted?
This typically occurs when the byte range of the document is altered after the signature is applied, or if the digest calculation during the plug-in signing process did not precisely match the final byte range of the file.
What is a PubSec callback in PDF signing?
PubSec (Public-Key Security) callbacks are API mechanisms utilized by signature plug-ins to handle authentication, certificate validation, and digest calculations securely during the PDF signing process.
Can an invalid certificate error be caused by missing intermediate certificates?
Yes. If the complete certificate chain (including intermediate and root certificates) is not correctly embedded in the signature or trusted by the local PDF reader, it will flag the certificate as invalid.
How do I ensure my PDF signature is an incremental update?
When applying a signature via an API or plug-in, you must configure the save process to append the signature data to the end of the file rather than rewriting the entire PDF, which invalidates previous contents.




