Authenticode Verification

  • Thread starter Thread starter Krish
  • Start date Start date
I want to programatically verify a Authenticode signed file. How do I
do this?

Use the X09Certificate class to get the certificate from the expected
signed file and sniff for expected properties of the certificate. The
following code snippet provides a quick example.

public static bool DoesFileHaveExpectedAuthenticodeSignature
(string fileName)
{
try
{
X509Certificate certificate =
X509Certificate.CreateFromCertFile(fileName);

// Do the properties of the certificate match what you
are looking for,
// such as the certificate.Issuer or
certificate.Subject
if (certificate.Subject.Contains("whatever text you
are looking ofr"))
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
// Handle the failure of getting the certificate
here. More than likely, the exception
// was caused because the file does not have an
Authenticode signature.
return false;

}
}
 
Use the X09Certificate class to get the certificate from the expected
signed file and sniff for expected properties of the certificate. The
following code snippet provides a quick example.


Thanks Bloyd. I will try this.
Kris
 
Back
Top