【问题标题】:How to add Timestamp attribute to certification detail when signing pdf file签署pdf文件时如何将时间戳属性添加到认证详细信息
【发布时间】: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


【解决方案1】:

总结一下cmets...

检查您的示例文档很明显,您应用的时间戳没问题。特别是,您应该得到您在证书查看器对话框屏幕截图中标记的较低消息:

另一方面,您的代码不会影响您是否获得您在该屏幕截图中标记的其他条目:

该条目是签名者 X.509 证书的扩展,其中该证书的颁发者提供时间戳服务的地址,该服务可用于为与该证书关联的私钥创建的签名添加时间戳。

因此,该条目不一定包含用于创建实际时间戳的服务器,它只是一个提议或建议。

因此,如果屏幕截图中连接两个标记的框声称标记的 TSA URL 和对安全时间戳时间的引用之间存在某种必要的关系,那就错了。

【讨论】:

    猜你喜欢
    • 2016-04-05
    • 2019-10-20
    • 2010-11-16
    • 2016-04-16
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 2017-05-16
    相关资源
    最近更新 更多