如何在装配中看到数字签名?

时间:2015-09-29 13:39:11

标签: c# .net winforms .net-assembly

我读过有关“签署具有强名称的大会”的文章;
http://resources.infosecinstitute.com/dot-net-assemblies-and-strong-name-signature/;
然后我学会了获取公钥和公钥令牌;
但问题是:; 如何从装配中获取数字签名?
以及如何从数字签名中提取哈希值? 我更喜欢使用ildasm;
 谢谢你;

1 个答案:

答案 0 :(得分:2)

如果您愿意,可以从C#中执行此操作:

// Load the certificate from your DLL file

var cert = X509Certificate.CreateFromSignedFile("path to your assembly");

// Create an instance of X509Certificate2

var cert2 = new X509Certificate2(cert);

// Use `GetCertHash()` to extract certificate's hash

var hash = cert2.GetCertHash();

有关所用类型的文档:

x509证书: https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate%28v=vs.110%29.aspx

X509Certificate2: https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2%28v=vs.110%29.aspx