mma
mma

Reputation: 401

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?

Upvotes: 0

Views: 563

Answers (1)

M Abd El-Rahman
M Abd El-Rahman

Reputation: 11

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

Upvotes: 1

Related Questions