CAPICOM - 验证SignedCode来自没有UI的Trusted Publisher

Chr*_*ohn 8 c# capicom authenticode digital-signature

我在.NET 3.0 C#应用程序中使用CAPICOM来检查exe文件上的Authenticode签名.我需要确保证书列为可信发布者.signedCode.Verify(true)如果证书尚未受信任,则使用将显示对话框,因此用户可以选择是否这样做.但是,signedCode.Verify(false)即使它不是来自受信任的发布者,也要验证签名 - 可能这只是检查证书是否有效.

如何在没有UI的情况下检查文件上的签名是否来自有效且受信任的证书?

Kar*_*gha 0

StrongNameSignatureVerificationEx您可能需要做的是通过 P/Invoke通过 mscoree.dll 函数公开:

[DllImport("mscoree.dll", CharSet=CharSet.Unicode)]
static extern bool StrongNameSignatureVerificationEx(string wszFilePath, bool fForceVerification, ref bool  pfWasVerified);
Run Code Online (Sandbox Code Playgroud)