Replace CAPICOM with .NET, validate certificate
My component is responsible for downloading files from the server. As part of validating a file, I used a CAPICOM (SignedCode object) to check if the certificate contains a specific string and calls the Validate method of the SignedCode object. If the file contains a certificate without the requested string in the name, the user was prompted if he trusts the file.
Since CAPICOM will be deprecated by Microsoft, I need to implement this logic using .NET libraries. How can I get the same functionality as the .NET libraries? Is there any example on the internet?
Thanks Zaki
+2
a source to share
1 answer
using System.Security.Cryptography;
// ....
byte[] SignData(byte[] toSign)
{
RSACryptoServiceProvider rsaCert =
GetCertificateWithPrivateKeyFromSomewhere(); // this method is yours
return rsaCert.SignData(toSign, new SHA1CryptoServiceProvider());
}
bool VerifyData(byte[] toVerify, byte[] signature)
{
RSACryptoServiceProvider rsaCert =
GetCertificateWithPublicKeyFromSomewhere(); // this method is yours
return rsaCert.VerifyData(toVerify, new SHA1CryptoServiceProvider(), signature);
}
0
a source to share