Electron代码内部签名流程
以下流程以购买数安时代的证书为例进行签名
刚购买证书的用户需根据商家提供方法提取证书
驱动下载流程地址:https://www.trustauth.cn/code-guide/33224.html
程序下载流程地址:https://www.trustauth.cn/code-guide/37988.html
访问以上链接,按文档下载操作安装程序
插上ukey(购买证书后商家寄来的一个类似U盘的东西)点击驱动查看并导出证书(导出的后缀名为.cer),然后将后缀名改成.pfx放到electron项目中。
在electron项目中打包配置中win下面加入一下代码:
verifyUpdateCodeSignature: false,
signingHashAlgorithms: [
“sha256”,
“sha1”
],
signDlls: true,
rfc3161TimeStampServer: “http://tsa.starfieldtech.com”,
timeStampServer: “http://tsa.starfieldtech.com”,
certificateFile: “config/test.pfx”, // 导出的证书
certificatePassword: “******” // 证书密码
示例:
win: {
target: [
{
target: ‘nsis’,
arch: [‘ia32’],
},
],
verifyUpdateCodeSignature: false,
signingHashAlgorithms: [
“sha256”,
“sha1”
],
signDlls: true,
rfc3161TimeStampServer: “http://tsa.starfieldtech.com”,
timeStampServer: “http://tsa.starfieldtech.com”,
certificateFile: “config/test.pfx”,
certificatePassword: “******”
}
打包前,由于这种方式会对项目内所有可签名文件进行签名,所以打包前请在驱动(设置-客户端设置)中设置单点登录,否则,没签名一个单文件就要输入一次密码,比较耗时间并且累死人。
打包过程中请不要访问任何网络,以防打包失败。
打包结束请拔下ukey并且保存好。
由于我们是双签,所以需要
rfc3161TimeStampServer: “http://tsa.starfieldtech.com”,
timeStampServer: “http://tsa.starfieldtech.com”,
这两个时间戳服务器地址,若由于地址失效导致打包签名失败,可以尝试换个地址尝试签名
数字签名时间戳
http://tsa.starfieldtech.com (亲测可用) http://timestamp.globalsign.com/scripts/timstamp.dll http://timestamp.comodoca.com/authenticode http://www.startssl.com/timestamp http://timestamp.verisign.com/scripts/timstamp.dll http://timestamp.sectigo.com
以上地址均为我百度所得,只用了第一个,其他的能否使用属于未知。
注意:双签务必加上rfc3161TimeStampServer和timeStampServer;
以上均为我个人在项目中的使用经验,不喜勿喷。