如何在 iTextSharp 签名有效时显示“✔”?

How to display "✔" when signature is valid with iTextSharp?

当受信任的证书时,我需要像这样在 pdf 中签名:

证书来源不明时显示“?”。

我可以签名,但不显示“✔”或“?”。

请参阅 PAdES 第 6 部分(又名 ETSI TS 102 778-6),更具体地说是标题为 "The visual representation of AdES signature verification".

的第 6 部分

我引用:

A conforming signature handler shall not display the result of the signature validation inside the page content.

NOTE: The conforming signature handler will use off-page display to present the verification result.

如果您正在寻求一种使用 iText(Sharp) 为 PDF 文件中签名的可视化表示添加绿色复选标记的方法,那么您正在寻求实现违反 PAdES-6 的方法,这将违反 ISO-32000-2。

我可以访问 ISO-32000-2 的第 12.8 节草案(我对其进行了编辑),这就是它的内容:

the information included in the appearance dictionary shall not be used by a signature verification handler at the time of signature verification. It is there strictly for the purpose of providing a way for a human verifier to perform their own verification of the visual representation. A PDF processor shall not incorporate the validation status of a signature (e.g. a checkmark for passed or an X for failed) into the appearance of the signature field.

换句话说:你的问题是错误的。根据 PDF 规范,您正在询问一种生成无效 PDF 的方法。

绿色复选标记、红色叉号、黄色矩形...这些都是关于签名状态(有效、无效、未知)的视觉指示,应由 [=29] 的应用程序使用=]使用 已签名的 PDF(例如 PDF 查看器)。您正在寻求一种通过 生成 签名 PDF 的应用程序添加此类符号的方法,这是 PDF 规范所禁止的。

你应该问的问题是:"when do I get a green check mark in a PDF viewer for a signed PDF with a valid signature?"

  • 如果您在 Adob​​e 的 CDS(已停产)或 ATTL(CDS 的后继者)程序中使用来自合作伙伴的证书,则此绿色复选标记将自动出现在 Adob​​e Reader 中。其他规则可能适用于其他观众。
  • 如果您使用的证书来自 CA,而该 CA 并未向 Adob​​e 支付费用以使其根证书位于 collection 受信任的根证书中,那么您应该将 CA 的根证书添加到受信任的您自己的 PDF 查看器的身份。这可以手动完成,但也有自动完成的方法。

阅读 http://itextpdf.com/book/digitalsignatures 了解更多信息。