我用
签署了点网的exe signcode.exe与SPC / PVK组合的文件需要读取在运行它自己的公共密钥,以便验证一些数据。我已经下了许多不同的途径。
我试过
X509证书executingCert = X509Certificate.CreateFromSignedFile(EXE);
executingCert然后空。我猜signcode不创建一个X509签名的文件,但如果有改变,我很高兴地走那条路的开关。
编辑 原来上面没有工作....我有我的空检查向后(!=!= = =):)
大会ASM = Assembly.GetExecutingAssembly(); 串EXE = asm.Location; x509证书executingCert = X509Certificate.CreateFromSignedFile(EXE); 如果(!executingCert = NULL) { Console.WriteLine(集结号签订); 字节[] = assemblyKey executingCert.GetPublicKey(); }解决方案
SignCode(对于.NET 1.0和1.1)使用验证码签名,其中据我所知,缺乏.Net框架管理接口。你可能会需要使用P / Invoke来调用Win32 API的程序,如在此发现KB文章:如何从验证码信息签名的可执行。可能你会需要使用 CryptQueryObject 这将让你的证书,然后你会很可能不得不寻找另一个例程拉从公开密钥。
看看这个相关的StackOverflow问题,其中有很多答案:来的WinVerifyTrust检查特定签名
I'm signing a dot net exe using
signcode.exe with an spc/pvk comboThe file needs to read its own Public Key at runtime in order to verify some data. I've gone down a number of different avenues.
I've tried
X509Certificate executingCert = X509Certificate.CreateFromSignedFile(exe);executingCert is then null. I'm guessing signcode isn't creating an X509 signed file, though if there's a switch to change that I'm happy to go that way.
edited Turns out the above does work.... I had my null check backwards (!= != ==) :)
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 (for .Net 1.0 and 1.1) uses Authenticode signing, which as far as I'm aware, lacks a .Net Framework managed interface. You will likely need to use P/Invoke to call routines in Win32 API such as those found in this KB article: How To Get Information from Authenticode Signed Executables. Likely you'll need to use CryptQueryObject which will get you the certificate, which you will then likely have to find another routine to pull the public key from.
Check out this related StackOverflow question which has a lot of answers: WinVerifyTrust to check for a specific signature?
更多推荐
如何阅读从签署C#EXE公钥
发布评论