C# Add Timestamp to PKCS#7 CMS Digital Signature problem

安稳与你 提交于 2020-08-10 18:49:29

问题


This question is the continuation of that one. I also try to communicate with a 3rd party AS2 server. I use the same code as the author of that post. This code (the corrected version) is:

private byte[] Sign(byte[] content)
{
    CmsSigner cmsSigner = new CmsSigner(_cert);
    cmsSigner.SignedAttributes.Add(new Pkcs9SigningTime(DateTime.Now));

    SignedCms signedCms = new SignedCms(new ContentInfo(content));
    signedCms.ComputeSignature(cmsSigner, true);

    return signedCms.Encode();
}

But I get the following error back from the server:

Unable to verify content integrity: Message digest mismatch in signature.

in spite of signedCms.CheckSignature(false); doesn't throw an exception.

Where should I search the reason of this error?

来源:https://stackoverflow.com/questions/63017981/c-sharp-add-timestamp-to-pkcs7-cms-digital-signature-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!