Answer the question
In order to leave comments, you need to log in
C#. How to make a detached signature of a CMS Signed Data file and verify it with a public key?
Good afternoon.
Can you please tell me how to make a detached signature of the CMS Signed Data file and check it with a public key?
The simplest version, I made the simplest version of the signature, right? How to check it with a public key?
thanks in advance
byte[] dataToSign = File.ReadAllBytes(@"C:\c\test.pdf");
SignedCms signedCms = new SignedCms(new ContentInfo(dataToSign),detached: true);
X509Certificate2 certificate = new X509Certificate2(@"C:\c\certificate.pfx", "mypass");
var cmsSigner = new CmsSigner(SubjectIdentifierType.SubjectKeyIdentifier , certificate);
//Set the digest algorithm SHA512.
cmsSigner.DigestAlgorithm = new Oid("2.16.840.1.101.3.4.2.3");
signedCms.ComputeSignature(cmsSigner);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question