Answer the question
In order to leave comments, you need to log in
EDS verification from 1C using C# is not performed. What are the differences?
In C #, it is not possible to perform the verification of the digital signature imposed in 1C. In sharpie I write:
X509Certificate2 certificate = new X509Certificate2(fileP12, "PASSWORD");
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)certificate.PrivateKey;
var hash = sha1.ComputeHash(new UnicodeEncoding.GetBytes(input));
rsa.SignHash(hash, CryptoConfig.MapNameToOID("SHA1"));
Answer the question
In order to leave comments, you need to log in
Your C# code makes a "naked" signature.
The cryptography manager in 1C creates a signature in PKCS7 format.
Accordingly, in C#, you need to check the signature in the PKCS7 (CMS) format.
SignedCms.CheckSignature
After a lot of dancing with the tambourine and with a lot of help from bonv , this is what happened:
using System.Security.Cryptography.Pkcs;
// ...
ContentInfo contentInfo = new ContentInfo(Encoding.UTF8.GetBytes(INPUT_MSG));
SignedCms signedCms = new SignedCms(contentInfo, true);
signedCms.Decode(READ_FROM_1C_FILE_SIG);
signedCms.CheckSignature(true);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question