今天在看书,做程序签名,结果不行,现在把 .net 程序签名的步骤记录了一下。
对程序进行强签名步骤
1 创建密钥对
sn -k myKeyPair.snk
2 对项目属性进行设置
但是强签名并不包含发行商信息。所以如果需要对程序进行更详细说明,可以使用证书签名(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这样的公司那里颁发,这样才能通过证书有效性验证。