1

我刚刚在我的 pdf 中添加了时间戳。签名有效。时间戳记号也是正确的(我已经检查过了)。但 adobe reader 告诉我“签名包含嵌入式时间戳,但无法验证”。

在此处输入图像描述

AttributeTable unsigned = signerInformation.getUnsignedAttributes();
Hashtable<ASN1ObjectIdentifier, Attribute> unsignedAttrHash = null;
if (unsigned == null) {
    unsignedAttrHash = new Hashtable<ASN1ObjectIdentifier, Attribute>();
} else {
    unsignedAttrHash = signerInformation.getUnsignedAttributes().toHashtable();
}

unsignedAttrHash.put(PKCSObjectIdentifiers.id_aa_signatureTimeStampToken, signatureTimeStamp);

SignerInformation newSignertInformation = SignerInformation.replaceUnsignedAttributes(si, new AttributeTable(unsignedAttrHash));

在 stackowerflow 找到了这段代码。有用。这真的是正确的代码。最后我有新的 SignerInformationStore 和新的 CMS Signed Data 像这样

CMSSignedData.replaceSigners(oldCMSSignedData, newSignerStore);

但也许我的 PDF 中缺少某些内容?证书之类的?

这是样本pdf

4

1 回答 1

2

签名时间戳中的消息印记似乎不正确。预计在此消息印记中具有签名值的 SHA256。

签名值的SHA256:

1b4532052d612ca32ae96b9a8e7aa6d64ae6c69dc00e1b7b31394ac3b54c4049

时间戳记令牌中的消息印记:

E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 
于 2013-07-25T07:54:00.533 回答