简体   繁体   中英

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

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?

you can change the project type to .net 5 by using project properties (right click on project -> properties) -> application and changed target framework from .net core 3.0 to .net 5.0 i hope it will help anybody

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM