背景
使用Electron 打的包直接安装会有提醒, 网上很多方式是使用cmd 的, 我补充一下powershell的

解决步骤
- 在服务商买 代码签名证书, 注意不是常见的 SSL证书哈
这里我先使用自签名证书了
设置环境变量
1 2 3 4 5 6 7 8 9
| $certPassword = ConvertTo-SecureString -String "123456" -Force -AsPlainText
$fileToSign= "D:\niumag\niumagfiber\NiumagSeed-linux-4.1.3-beta.610-x64.exe"
$signtoolPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe"
$timestampServer = "http://timestamp.digicert.com"
|
创建根证书并导出
1 2 3 4
| $cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=AmanoCert" -KeyUsage DigitalSignature -KeyAlgorithm RSA -KeyLength 2048 -CertStoreLocation "Cert:\CurrentUser\My"
Export-PfxCertificate -Cert $cert -FilePath "AmanoCert4.pfx" -Password $certPassword
|
签名
1
| & "$signtoolPath" sign /debug -f AmanoCert4.pfx -p 123456 /fd SHA256 /tr $timestampServer /td SHA256 -a $fileToSign
|
效果
签名效果

属性效果
