Skip to content

Simple package with the purpose of validating the signature of a file using the WinTrust API.

License

Notifications You must be signed in to change notification settings

ricaun-io/ricaun.Security.WinTrust

Repository files navigation

ricaun.Security.WinTrust

Visual Studio 2022 Nuke License MIT Build nuget

Description

Simple package with the purpose of validating the signature of a file using the WinTrust API.

Usage

WinTrust

Utility class to validate the signature of a file is trusted using the WinTrust API.

bool result = WinTrust.VerifyEmbeddedSignature(@"C:\Windows\explorer.exe");

Certificate

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

Dummy Certificate

The signfile.pfx is a dummy certificate created to sign the ConsoleAppSignedNotTrusted.exe file and test the WinTrust.VerifyEmbeddedSignature method.

Release

License

This project is licensed under the MIT License.


Do you like this project? Please star this project on GitHub!

About

Simple package with the purpose of validating the signature of a file using the WinTrust API.

Resources

License

Stars

Watchers

Forks