We are trying to add certification signature to avoid further modifications on the document after the first signature. But whenever we set DocMDP tranform with the value 2 (that should allow new signatures) Adobe reader disables the option to digitally sign the document although on the secutity properties it shows that signatures are allowed. Is that a bug in Adobe Reader or are we doing something wrong on our code?
PDFBox version:
try (PDDocument document = PDDocument.load(conteudoStream, MemoryUsageSetting.setupTempFileOnly())) {
PDSignature signature = new PDSignature();
signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE);
signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED);
signature.setName("My System");
signature.setLocation(SOURCE_LOCATION);
signature.setReason("Assinatura Digital de documento.");
boolean isFirst = document.getSignatureDictionaries().isEmpty();
document.addSignature(signature);
if (isFirst) {
SigUtils.setMDPPermission(document, signature, 3);
}
ExternalSigningSupport externalSign = PdfBoxHelper.saveIncrementalForExternalSigning(document, output);
externalSign.setSignature(signature);
}
}
Itext version:
Rectangle rect = new Rectangle(36, 748, 144, 780);
PdfSigner signer = new PdfSigner(new PdfReader(inputPath), new FileOutputStream(outputPath), false);
signer.setFieldName("signature");
signer.setCertificationLevel(PdfSigner.CERTIFIED_FORM_FILLING);
System.out.println("provider: "+Util.getProvedor().getName());
signer.signDetached(new BouncyCastleDigest(), new PrivateKeySignature(key), DigestAlgorithms.SHA512, "SunMSCAPI"), chain, null, null, null, 0, PdfSigner.CryptoStandard.CMS);
Security properties:
Signature disabled:
We expected that modifications on the document would be forbidden but new signatures would be allowed as the description for DocMDP should allow "Form fill-in and digital signatures" and Adobe Reader list signatures as allowed although it greys out the option to sign.
Edit: As requested I've included a sample certified PDF. We are using Adobe Reader version 2023.001.20143. It's certifies with DocMPD transform P=2. Adobe Reader show signatures as allowed but Digitally Sign button is disabled.
Edit 2: included also a sample using iText instead of PDFBox.
Edit 3: searched for sample certified pdfs on the Internet and for none of them the Digitally Sign button on Adobe Reader was enabled. I'm suspecting it's a bug on Adobe Reader. Does anyone knows of a certified PDF that Adobe Reader would allow new signatures so we can compare what's different on the PDF structure?