問題描述
我正在為安裝程序 DLL 編寫一個函數,以驗證系統上已安裝的 EXE 文件的 Authenticode 簽名.
I'm writing a function for an installer DLL to verify the Authenticode signature of EXE files already installed on the system.
函數需要:
A) 驗證簽名是否有效.
B) 驗證簽名者是我們的組織.
A) verify that the signature is valid.
B) verify that the signer is our organization.
因為這是在安裝程序中,并且因為它需要在較舊的 Win2k 安裝上運行,所以我不想依賴 CAPICOM.dll,因為它可能不在目標系統上.
Because this is in an installer, and because this needs to run on older Win2k installations, I don't want to rely on CAPICOM.dll, as it may not be on the target system.
WinVerifyTrust API 可以很好地解決(A).
The WinVerifyTrust API works great to solve (A).
我需要找到一種方法將已知證書(或其中的屬性)與簽署相關 EXE 的證書進行比較.
I need to find a way to compare a known certificate (or properties therein) to the one that signed the EXE in question.
推薦答案
你應該使用 CryptQueryObject.
這篇 KB 文章演示了用法:如何從 Authenticode 簽名的可執行文件中獲取信息.
This KB-article demonstrates the use: How To Get Information from Authenticode Signed Executables.
對于詢問如何在沒有 Windows-API 的情況下執行此操作的評論者,我不知道任何可以執行此操作的庫,但此處記錄了格式:Windows Authenticode 可移植可執行簽名格式
To the commenter that asked about how to do it without the Windows-APIs, I am not aware of any library that can do it, but the format is documented here: Windows Authenticode Portable Executable Signature Format
這篇關于在沒有 CAPICOM 的情況下驗證 EXE 上的 Authenticode 簽名 - C++的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!