Answer#
What signing gives you. Microsoft's SignTool page says that "digital signatures protect files from tampering and enable users to verify the signer based on a signing certificate." A signed .exe or installer shows your name as publisher instead of "unknown publisher", and any change to the file afterwards invalidates the signature. It does not prove the program is harmless; it proves who signed it.
What you need. A code-signing certificate from a certificate authority, or a cloud signing service that holds the key for you, and SignTool. SignTool "is available as part of the Windows Software Development Kit (SDK)".
The command. From the SignTool page, this form signs and time-stamps with a certificate in a file; the page's own example uses the SHA256 algorithm:
signtool sign /f MyCert.pfx /p <password> /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 MyFile.exe(This is a template assembled from options documented on that page; it was not run. Replace the file, password and time-stamp URL with your own. Many teams keep the key in a hardware token or a cloud service instead of a .pfx file; the documentation lists /n, /sha1 and /dlib for selecting a certificate in a store or a signing library.)
What the options mean (from the page):
/fd SHA256is the file digest algorithm. The page notes that if/fdis not given, "the command generates an error" in current SDK builds./tr URLis an RFC 3161 time-stamp server and/td SHA256the digest it should use; without/tdthe command "generates an error" when time-stamping./apicks the best certificate automatically instead of naming one.
Verify the result:
signtool verify /pa /v MyFile.exeWhy timestamp. Certificates expire. The page states that if no time-stamp option is given, "the signed file isn't time stamped". With a timestamp from a trusted server, the signature can be shown to have been made while the certificate was valid, so the file does not turn "unsigned" on the day the certificate runs out. Always time-stamp release files.
Order of work. Sign the executable first, then build the installer that contains it, then sign the installer too.
Common mistakes#
- Putting the certificate password in a script in the repository. Use your CI system's secret store.
- Signing without a timestamp.
- Signing only the installer, so the installed
.exeis unsigned.
Related questions#
Does a signature remove the SmartScreen warning at once?#
This thread makes no claim about it: how Windows judges a new publisher is Microsoft's decision, and its documentation is the place to read the current rules.
Sources#
- Microsoft, SignTool: https://learn.microsoft.com/windows/win32/seccrypto/signtool (read 2026-12-05)