Signature on encrypted documents results invalid signature

When signing a crypted document with privileges, the final document has an invalid signature. Adobe states “Document has been altered or corrupted since ist was signed”.

This question may bei connected to PDFJAVA-39851

Code Example:

import jpype.imports
jpype.startJVM(jpype.getDefaultJVMPath(), classpath='aspose-pdf-22.9-jdk16.jar')
Document = jpype.JClass("com.aspose.pdf.Document")
License = jpype.JClass("com.aspose.pdf.License")

PdfFileSignature = jpype.JClass("com.aspose.pdf.facades.PdfFileSignature")
PKCS7 = jpype.JClass("com.aspose.pdf.PKCS7")

pdflic = License()
pdflic.setLicense(jpype.JString("../Aspose.PDF.Java.lic"))

# Document with permissions and owner-passwort <secret>
pdf = Document('sign_example_with_priv.pdf', 'secret')
sig = PdfFileSignature(pdf)
pkcs = PKCS7("sign_example.pfx", "geheim")
sig.sign("signature1", pkcs)
sig.save('sign_example_with_priv_and_signed.pdf')
sig.close()

@HorstHasenstab

Would you please try to change the sequence i.e. encrypt document first and then sign it because any change to the signed PDF document revokes its validity. In case issue still persists, please share your sample PDF along with other sample files with us. We will test the scenario in our environment and address it accordingly.

sign_example.zip (895.0 KB)
Hi Ali,
thanks for your response. Thats exactly what we did.

1st: encryt
2nd sign

We can do both with aspose. The code above contains only the second step.

sign_example_with_priv.pdf (181.0 KB)
sign_example_with_priv_and_signed.pdf (718.5 KB)

Kind regards

@HorstHasenstab

An investigation ticket as PDFJAVA-42179 has been logged in our issue tracking system for further analysis. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.