简体   繁体   中英

Programmatically verify digital signature of .exe in C#

within the C# code of my.dll I want to verify the digital signature of the.exe that is calling my.dll. I am looking for a way to do something like SignTool Verify [...] from code.

The digital signature I want to check is displayed on the digital signature tab in the windows file explorer. As an example, here is an example screenshot of this tab.

在此处输入图像描述

How do I access the digital signature of the.exe from C# code? What is the best way to do this? Does anyone have an example?

I use reflection to compare the cert. Sample like below:

string dllPath = "";
Assembly assembly = Assembly.LoadFile(dllPath);
var modules = assembly.GetModules();
var cert = modules[0].GetSignerCertificate();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM