使用自签名证书签名exe程序
最近使用python写了一个有意思的程序,打包成exe之后,丢出去杀毒软件会报毒,其实没有病毒,查询资料得知,现在的exe要签名,才能避免杀毒软件报毒,于是我今天自己给自己的exe签了个名,记录一下过程如下。其实exe自签名没什么用,我就是为了证明,这个exe是我开发的而已,因为exe属性中有我的签名。
ailx10
网络安全优秀回答者
互联网行业 安全攻防员
去咨询
(1)使用powershell生成自签名证书,其中保存路径和密码需要修改成自己的
# 生成自签名证书
New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=MyTestCertificate" -KeyUsage DigitalSignature -CertStoreLocation "Cert:\CurrentUser\My"# 导出证书为 .pfx 文件(带密码保护)
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Where-Object { $_.Subject -eq "CN=MyTestCertificate" }
Export-PfxCertificate -Cert $cert -FilePath "C:\Users\ailx10\Desktop\2\MyTestCert.pfx" -Password (ConvertTo-SecureString -String "Ailx10Ha" -Force -AsPlainText)
(2)使用微软的signtool工具(github上可以下载)和自签名证书对自己的exe程序进行签名
signtool sign /f "C:\Users\ailx10\Desktop\2\MyTestCert.pfx" /p Ailx10Ha /tr http://timestamp.digicert.com /td sha256 /fd sha256 "C:\Users\ailx10\Desktop\2\main.exe"
签名成功后,就可以在属性中查看数字签名了,你可以在步骤一中修改签名者姓名,表示这个软件是你开发的
所属专栏 · 2025-05-18 08:24 更新
信息安全入门
ailx10
发布于 2025-03-12 20:11・江苏