【发布时间】:2021-12-24 06:23:32
【问题描述】:
我想在证书中显示Timestamp属性如图所示
我应该在签名中设置什么?
这是我添加签名信息的代码:
private SignerInformation signTimeStamp(SignerInformation signer) throws IOException, TSPException {
AttributeTable unsignedAttributes = signer.getUnsignedAttributes();
ASN1EncodableVector vector = new ASN1EncodableVector();
if (unsignedAttributes != null) {
vector = unsignedAttributes.toASN1EncodableVector();
}
byte[] token = this.tsaClient.getTimeStampToken(signer.getSignature());
ASN1ObjectIdentifier oid = PKCSObjectIdentifiers.id_aa_signatureTimeStampToken;
ASN1Encodable signatureTimeStamp = new Attribute(oid, new DERSet(ASN1Primitive.fromByteArray(token)));
vector.add(signatureTimeStamp);
Attributes signedAttributes = new Attributes(vector);
// replace unsignedAttributes with the signed once
return SignerInformation.replaceUnsignedAttributes(signer, new AttributeTable(signedAttributes));
}
【问题讨论】:
-
请分享使用您的代码签名的 pdf。
-
@mkl mkl。是的。请帮我检查一下。谢谢你。 drive.google.com/file/d/12LZFn-sveKrcVvagk7QbhKf7a4Lxo-7Q/…
-
@mkl 请帮我检查一下。非常感谢。
-
@KJ “有趣的旧 Acrobat 报告不允许的操作类型:URI ...” - 嗯,有一个指向外部位置的链接注释。禁止这样做是非常值得怀疑的。这可能就是它不再被禁止的原因。
-
@mkl 是的。我看到了。
标签: pdf timestamp digital-signature signature