Question

I want to verify file certificate. The signature was generating using sha1 and RSA. When right clicking the file, selecting properties, Digital Signatures, Details I see the following:

enter image description here

I have C++ code that verifies such a signature, using WinVerifyTrust.

However I googled - I just couldn't find C# way of doing it. I tried to export the certificate to file, and then took from the file properties the Message Digest: enter image description here Create X509 Certificate, and verify hash - nothing worked.

Any help will be appreciated.

CLARIFICATION

In short: Given a file, how can I verify it is signed by a trusted certificate?

Was it helpful?

Solution

You are looking for : X509Certificate.CreateFromSignedFile

 try
  {
  X509Certificate theSigner = X509Certificate.CreateFromSignedFile("c:\\r\\1.dll");
  Console.Write("certificate info :"+ theSigner.GetCertHashString());
  }
  catch (Exception ex)
  {
         Console.WriteLine("No digital signature ");


  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top