Simple package with the purpose of validating the signature of a file using the WinTrust API.
Utility class to validate the signature of a file is trusted using the WinTrust API.
bool result = WinTrust.VerifyEmbeddedSignature(@"C:\Windows\explorer.exe");
Utility class to check the Certificate
file is signed, subject and issuer.
bool result = Certificate.IsSignedFile(@"C:\Windows\explorer.exe");
If you want to get the subject or issuer of the file, you can use the following methods:
string subject = Certificate.GetSignedFileSubject(@"C:\Windows\explorer.exe");
string issuer = Certificate.GetSignedFileIssuer(@"C:\Windows\explorer.exe");
If you want to get a specific field of the subject or issuer, you can use the following methods:
string communName = Certificate.GetSignedFileSubject(@"C:\Windows\explorer.exe", "cn"); // "Microsoft Windows"
string organization = Certificate.GetSignedFileIssuer(@"C:\Windows\explorer.exe", "o"); // "Microsoft Corporation"
Some of the most common RDNs and their explanations are as follows:
CN: CommonName
O: Organization
L: Locality
S: StateOrProvinceName
C: CountryName
The signfile.pfx is a dummy certificate created to sign the ConsoleAppSignedNotTrusted.exe
file and test the WinTrust.VerifyEmbeddedSignature
method.
This project is licensed under the MIT License.
Do you like this project? Please star this project on GitHub!