【发布时间】:2015-11-12 11:20:07
【问题描述】:
所以我最近一直在做 PDF 文档的签名工作,今天我遇到了一个新奇的问题。因此,当我签署文档(文档实际上是在服务器上签名)并在我的机器上打开该文档时,签名显示有效并且它启用了 LTV,因此几乎可以按预期工作。但是,当我在老板的计算机上打开同一个文档时,它显示即使在证书被信任后也无法验证签名的身份,但是如果我打开证书属性,它会说证书有效并且吊销已成功执行。这可能是什么原因?
图 1:证书本身是可信的。
图 2:中间证书是可信的。
图 3:受信任的根证书
签名文件:https://drive.google.com/file/d/0B9RyqgJoa6W8WlBLemVETXJRU0U/view?usp=sharing
另一个奇怪的事情,对于时间戳签名,当我将根证书作为受信任的根证书添加到 adobe 时,它说 LTV 未启用,但是如果我将 GlobalTrustFinder 证书本身添加为受信任的证书,它会说 LTV已启用。有什么理由这样做吗?
任何帮助将不胜感激
将 LTV 添加到现有签名块以及添加时间戳签名的代码:
private void SignDocumentSigningBlockAddLTVVerification(PdfStamper stamper, Certificate certificate)
{
LtvVerification ltvVerification = stamper.LtvVerification;
List<string> signatureFieldNames = stamper.AcroFields.GetSignatureNames();
ITSAClient tsaClient = new TSAClientBouncyCastle(_settingManager["DocumentSigningTimestampingServiceAddress"], String.Empty, String.Empty, Int32.Parse(_settingManager["DocumentSigningEstimatedTimestampSize"]), _settingManager["DocumentSigningEncryptionHashAlgorithm"]);
IOcspClient ocspClient = new OcspClientBouncyCastle();
ICrlClient crlClient = new CrlClientOnline(SignDocumentSigningBlockBuildChain(new X509Certificate2(certificate.Bytes, certificate.Password, X509KeyStorageFlags.Exportable)).ToList());
PdfPKCS7 pkcs7 = stamper.AcroFields.VerifySignature(signatureFieldNames.Last());
if (pkcs7.IsTsp)
{
ltvVerification.AddVerification(signatureFieldNames.Last(), ocspClient, crlClient, LtvVerification.CertificateOption.SIGNING_CERTIFICATE, LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO);
}
else
{
foreach (string name in stamper.AcroFields.GetSignatureNames())
{
ltvVerification.AddVerification(name, ocspClient, crlClient, LtvVerification.CertificateOption.WHOLE_CHAIN, LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO);
}
}
ltvVerification.Merge();
PdfSignatureAppearance appearance = stamper.SignatureAppearance;
LtvTimestamp.Timestamp(appearance, tsaClient, null);
}
亲切的问候
【问题讨论】:
标签: pdf itextsharp itext signing