在LTV认证签名之后,PDF显示"文档已被更改"

时间:2018-05-14 11:05:52

标签: c# pdf itext

过去几个月,我一直与iText和GlobalSign合作,对PDF文件进行数字签名和认证,并遇到一个问题。

当我刚刚签署pdf然后尝试启用LTV时,它完美无缺,但是当我进行认证签名然后尝试启用LTV时,它启用LTV并显示"已对此文档进行了更改认证方允许的#34;。

签名和LTV启用后的最终输出:

Final Output after sign and ltv enabling

我想要的是在启用LTV认证后pdf应该显示"文档未被修改,因为此签名已被应用"。

我曾尝试将crlbytes添加到Signature但它不起作用

用于将签名添加到文档的代码:

using (FileStream os = new FileStream(dest, FileMode.CreateNew))
{
    PdfReader reader = new PdfReader(src);
    IExternalSignatureContainer external = new MyExternalSignatureContainer(sig);
    MakeSignature.SignDeferred(reader, fieldname, os, external);
}

用于将LTV添加到文档的代码:

using (FileStream fos = new FileStream(dest, FileMode.CreateNew))
{
    PdfReader r = new PdfReader(src);
    PdfStamper stp = new PdfStamper(r, fos, '\0', true);
    LtvVerification v = stp.LtvVerification;
    AcroFields fields = stp.AcroFields;
    List<String> names = fields.GetSignatureNames();
    String sigName = names[names.Count - 1];
    PdfPKCS7 pkcs7 = fields.VerifySignature(sigName);
    if (pkcs7.IsTsp)
    {
        v.AddVerification(sigName, ocsp, crl,
                LtvVerification.CertificateOption.SIGNING_CERTIFICATE,
                LtvVerification.Level.OCSP_CRL,
                LtvVerification.CertificateInclusion.YES);
    }
    else
    {
        foreach (string name in names)
        {
            v.AddVerification(name, ocsp, crl,
                    LtvVerification.CertificateOption.WHOLE_CHAIN,
                    LtvVerification.Level.OCSP_CRL,
                    LtvVerification.CertificateInclusion.NO);
        }
    }

    stp.Close();
    r.Close();
}

是否有任何方法可以启用认证签名LTV并在pdf上显示消息为&#34;自应用此签名后文档未被修改&#34;

已编辑:

我也尝试了以下代码,但它没有工作

X509Certificate[] mObjX509CertChain = GlobalSignAPI.CreateChain(mStrSigningCertificate, mStrCACertificate);

ICollection<byte[]> crlBytes = new List<byte[]>
{
    mObjX509CertChain[0].GetEncoded(),
    mObjX509CertChain[1].GetEncoded()
};
byte[] mObjBEncodedPKCS7 = mObjPKCS7.GetEncodedPKCS7(mObjByteHash, mObjTSAClient, mObjByteOC, crlBytes, CryptoStandard.CADES);

0 个答案:

没有答案