如何从已签名的C#exe中读取公钥

我正在签署一个dot net exe
signcode.exe with an spc/pvk combo
该文件需要在运行时读取自己的公钥以验证某些数据。我走了很多不同的途径。 我试过了
X509Certificate executingCert = X509Certificate.CreateFromSignedFile(exe);
executionCert则为null。我猜测signcode没有创建一个X509签名文件,但如果有一个改变的转换,我很高兴这样做。 编辑 事实证明以上工作....我向后检查了我的空检查(!=!= ==):)
Assembly asm = Assembly.GetExecutingAssembly();
string exe = asm.Location;
X509Certificate executingCert = X509Certificate.CreateFromSignedFile(exe); 

if (executingCert != null)
{
    Console.WriteLine("Assembly is signed");
    byte[] assemblyKey = executingCert.GetPublicKey();
}
    
已邀请:
SignCode(用于.Net 1.0和1.1)使用Authenticode签名,据我所知,缺少.Net Framework托管接口。您可能需要使用P / Invoke来调用Win32 API中的例程,例如此知识库文章中的例程:如何从Authenticode签名的可执行文件中获取信息。可能你需要使用CryptQueryObject来获取 证书,您可能必须找到另一个从中提取公钥的例程。 看看这个有很多答案的StackOverflow问题:WinVerifyTrust来检查特定的签名?     
尝试类似的东西:
Assembly.GetEntryAssembly().GetName().GetPublicKey()
在这种情况下我使用了GetEntryAssembly,但当然你可以在任何加载的程序集上调用该方法。     

要回复问题请先登录注册