如何从已签名的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();
}
没有找到相关结果
已邀请:
2 个回复
蔬谢窗港
玖料萄
在这种情况下我使用了GetEntryAssembly,但当然你可以在任何加载的程序集上调用该方法。