我想在证书中显示时间戳属性,如图片所示

我应该在签名中设置什么?
这是我添加符号信息的代码:
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));
}发布于 2021-11-17 16:43:01
总结这些评论..。
检查示例文档,可以清楚地看到您应用的时间戳是正常的。特别是,您应该获得在证书查看器对话框屏幕快照中标记的较低的消息:

另一方面,您的代码对您是否得到在屏幕截图中标记的其他条目没有影响:

该条目是签名者X.509证书的扩展,在该证书的签发方提供时间戳服务的地址,该时间戳服务可用于与该证书关联的私钥创建的时间戳签名。
因此,条目并不一定包含用于创建实际时间戳的服务器,它只是一个命题或建议。
因此,如果屏幕截图中与两个标记连接的框声称标记的TSA与安全时间戳时间的引用之间存在某种必要的关系,则这是错误的。
https://stackoverflow.com/questions/69933844
复制相似问题