【发布时间】:2021-10-07 14:29:48
【问题描述】:
我正在尝试使用 BouncyCastle CMS 签署 PDF。签名有效,但 Adobe Reader 告诉我它还没有为 LTV 做好准备。
据我所知,CRL 嵌入在 CMS SignedData 中。证书也是嵌入的。还嵌入了时间戳。
签名是分离的签名,放在“预留空间”中。
为什么签名仍未准备好 LTV?我是不是在做一些明显的错误?
签名测试-PDF:http://www.filedropper.com/outputx
代码:
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
// CertificateChain
List<Certificate> certList = Arrays.asList(certChain);
try {
Hashtable signedAttrs = new Hashtable();
X509Certificate signingCert = (X509Certificate) certList.get(0);
gen.addSignerInfoGenerator(new JcaSimpleSignerInfoGeneratorBuilder().setProvider("BC")
.setSignedAttributeGenerator(new AttributeTable(signedAttrs))
.build("SHA256withRSA", privKey, signingCert));
gen.addCertificates(new JcaCertStore(certList));
boolean embedCrls = true;
if (embedCrls) {
X509CRL[] crls = fetchCRLs(signingCert);
for (X509CRL crl : crls) {
gen.addCRL(new JcaX509CRLHolder(crl));
}
}
// gen.addOtherRevocationInfo(arg0, arg1);
CMSProcessableByteArray processable = new CMSProcessableByteArray(IOUtils.toByteArray(content));
CMSSignedData signedData = gen.generate(processable, false);
if (tsaClient != null) {
signedData = signTimeStamps(signedData);
}
return signedData.getEncoded();
} catch (Exception e) {
throw new RuntimeException(e);
}
【问题讨论】:
-
LTV 信息与
AddValidationInformation.java示例一起添加 -
感谢 Tilman,我们(仍然)使用旧式 Adobe 签名。
标签: pdf pdf-generation pdfbox bouncycastle pkcs#7