問題描述
不安裝證書可以使用 MSBuild 的 SignFile 嗎? (Can MSBuild's SignFile be used without installing the certificate?)
我有一個 ClickOnce 應用程序,我已對其進行了更新,以便使用帶有 MSBuild 的現代部署 Jenkins Pipeline 進行部署。這項工作的一部分是對 .manifest 和 .application 文件進行簽名。
之前我們使用 和 MSBuild 來簽署這些文件,使用安裝在用戶個人文件中的證書存儲在構建機器上。它適用於:
<SignFile SigningTarget="MyApp.exe.manifest"
CertificateThumbprint="1a 9f ..."
TimestampUrl="http://timestamp.verisign.com/scripts/timstamp.dll" />
<SignFile SigningTarget="MyApp.application"
CertificateThumbprint="1a 9f ..."
TimestampUrl="http://timestamp.verisign.com/scripts/timstamp.dll" />
但是,在 21 世紀,我們更喜歡在版本控制中或通過 API 在秘密存儲中提供構建所需的一切,這樣我們就不再依賴構建服務器處於某種狀態。
那麼我們如何在不需要安裝證書的情況下使用 SignFile 對 ClickOnce 清單和應用程序進行簽名?
參考解法
方法 1:
It seems like the old mage.exe is more full‑featured than SignTool.
So I copied mage.exe to my project dependencies folder from C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools
, then in MSBuild, this worked for me:
<Message Text="Signing APP manifest (.exe.manifest)" />
<Exec Command="Dependencies\mage.exe ‑sign $(MyAppManifest).exe.manifest ‑CertFile MyLocalKey.pfx ‑Password MyPassword123" />
Then I did something very similar to that for the deployment manifest (.application) file.
Apparently the newer versions of mage.exe can indeed support SHA‑256, contrary to some web pages I found on the topic (perhaps they were older).
(by Patrick Szalapski、Patrick Szalapski)