我们正在尝试添加认证签名,以避免在第一次签名后对文档进行进一步修改。但是每当我们将 DocMDP 转换设置为值 2(应该允许新签名)时,Adobe 阅读器会禁用对文档进行数字签名的选项,尽管在安全属性上它显示允许签名。这是 Adobe Reader 中的错误还是我们的代码有问题?
PDFBox 版本:
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);
}
}
正文版:
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);
我们预计将禁止对文档进行修改,但允许新签名,因为 DocMDP 的描述应该允许“表单填写和数字签名”,而 Adobe Reader 允许列出签名,尽管它使签名选项变灰。