自己製作的.EXE檔案,會被WINDOWS誤判異常有毒文件,如何建立數位簽名解決

因為自己工作上的需求,寫了一個PYTHON的小程式分享給同事們使用,但是前年開始被公司的WIN10電腦,誤判是有問題的文件不能執行。
自己除錯後,要再數位簽名,才能防止被誤判是有問題的執行檔。
所以給自己一個紀錄,防止以後遇到類似的位題又在那邊花時間找解決方案…冏

***** 0) PYTHON程式轉成可執行檔(.PY to .exe)。
pyinstaller -F PYTHON_250630.py

***** 1) 建立適合使用的簽名檔,憑證有效期預設為一年。
c:
cd "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64"
Set-ExecutionPolicy Bypass -Scope Process
$cert = New-SelfSignedCertificate `
-DnsName "使用者網址.com.tw" `
-CertStoreLocation "cert:\LocalMachine\My" `
-Type CodeSigning `
-Subject "CN=使用者名稱, E=使用者信箱帳號@信箱網址.com.tw"
$pwd = ConvertTo-SecureString -String "helloworld" -Force -AsPlainText
Export-PfxCertificate -cert $cert -FilePath jircodecert250630.pfx -Password $pwd

***** 2) 已產出的EXE可執行檔和建立的簽名憑證結合,加入時間戳產出有數位簽名的可執行檔。
c:
cd "C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64"
signtool.exe sign /f .\jircodecert250630.pfx /fd SHA256 /p helloworld /tr http://timestamp.sectigo.com /td SHA256 .\PYTHON_250630.exe

其它說明參考:
https://developer.microsoft.com/zh-tw/windows/downloads/windows-sdk/
https://stackoverflow.com/questions/78982240/sap-s4-hana-login-via-scripting-no-longer-showing-sap-gui-logon-dialog
https://ithelp.ithome.com.tw/articles/10281279
https://github.com/jiachengx/ironmen/blob/main/gencert.ps1
https://ooorito.com/code-singing-with-signtool/

Be the first to reply

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

請輸入下列驗證碼計算後阿拉伯數字 (Translate it, if not Taiwanese to post reply) *