今天在看书,做程序签名,结果不行,现在把 .net 程序签名的步骤记录了一下。

对程序进行强签名步骤
1 创建**对
sn -k myKeyPair.snk

2 对项目属性进行设置

如何.net 程序强签名与手工证书签名说明


但是强签名并不包含发行商信息。所以如果需要对程序进行更详细说明,可以使用证书签名(SPC)

以下是 sign.bat 文件内容

[php] view plain copy
  1. @echo 删除旧文件  
  2. del testCert.*  
  3.   
  4. @echo 生成测试证书  
  5. @echo 按提示输入密码  
  6. @echo makecert 参数说明  
  7. @echo -r 创建自签署证书。  
  8. @echo -sky 指定主题**类型 必须是下列之一:signature(其中指出**用于数字签名),exchange(其中指出**用于**加密和**交换)  
  9. @echo 这里 -sky要用signature  
  10. makecert -r -sv testCert.pvk  -sky signature -ss testCertStore testCert.cer  
  11.   
  12. @echo 生成 spc文件  
  13. cert2spc TestCert.cer TestCert.spc  
  14.   
  15. @echo net 1.1 签名  
  16. @echo // singcode -spc TestCert.spc -v myprivateKey.pvk TEST.dll  
  17.   
  18. @echo net. 4 签名  
  19. @echo 还有转 pvk 格式  
  20. pvk2pfx -pvk TestCert.pvk -spc TestCert.spc -pfx TestCert.pfx -pi 这里填makecert的密码  
  21.   
  22. @echo 对程序进行签名  
  23. signtool sign /v /f testCert.pfx /p yehaoen test.dll  

真正的证书应该从类似Verisign这样的公司那里颁发,这样才能通过证书有效性验证。

相关文章: