2013-10-22 21 views

回答

0

我认为你可以使用

X509Certificate.CreateFromSignedFile()

如果你通过了.exe或.msi程序或任何签名的文件,以这种方法的名称,它会创建一个X509Certificate对象。然后您可以使用GetName()方法获取认证发布者信息。如果你还没有发现它,下面的代码应该让你开始。

using System; 
using System.Security.Cryptography.X509Certificates; 

namespace ConsoleApplication1 
{ 
    public class ConsoleApplication1 
    { 
     [STAThread] 
     static void Main(string[] args) 
     { 
      X509Certificate xcert = null; 
      try 
      { 
       xcert = X509Certificate.CreateFromSignedFile(args[0]); 
       Console.WriteLine(args[0] + "\t" + xcert.GetName() + "\t" + xcert.GetPublicKeyString()); 
      } 
      catch (Exception e) { Console.WriteLine(args[0] + ": Unable to readDER-encoded signature."); } 
     } 
    } 
} 
相关问题