今天在看書,做程序簽名,結果不行,現在把 .net 程序簽名的步驟記錄了一下。
但是強簽名並不包含發行商信息。所以如果需要對程序進行更詳細說明,可以使用證書籤名(SPC)
以下是 sign.bat 文件內容
@echo 刪除舊文件
del testCert.*
@echo 生成測試證書
@echo 按提示輸入密碼
@echo makecert 參數說明
@echo -r 創建自簽署證書。
@echo -sky 指定主題密鑰類型 必須是下列之一:signature(其中指出密鑰用於數字簽名),exchange(其中指出密鑰用於密鑰加密和密鑰交換)
@echo 這裏 -sky要用signature
makecert -r -sv testCert.pvk -sky signature -ss testCertStore testCert.cer
@echo 生成 spc文件
cert2spc TestCert.cer TestCert.spc
@echo net 1.1 簽名
@echo // singcode -spc TestCert.spc -v myprivateKey.pvk TEST.dll
@echo net. 4 簽名
@echo 還有轉 pvk 格式
pvk2pfx -pvk TestCert.pvk -spc TestCert.spc -pfx TestCert.pfx -pi 這裏填makecert的密碼
@echo 對程序進行簽名
signtool sign /v /f testCert.pfx /p yehaoen test.dll
真正的證書應該從類似Verisign這樣的公司那裏頒發,這樣才能通過證書有效性驗證。