FAQ - Help and questions

How do I code-sign a Windows executable, and why does the signature need a timestamp?

#code-signing#windows#signtool#releasepublished 0 replies0 views
ReplyWatch
Share
Hacker NewsRedditLinkedInE-mail

Short answer

Code signing attaches a digital signature, made with a certificate, that shows who published a file and that it was not changed afterwards. SignTool from the Windows SDK does it, with named digest algorithms, and a timestamp keeps the signature valid after the certificate expires. Not run here.

Checked with not run here. No certificate was available for this thread and SignTool was not executed. The commands and option meanings are from Microsoft's SignTool documentation, read on 2026-12-05.

Frequently asked question, written and answered by the Ruststudio team. Replies are open: corrections are welcome.

#1

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:

text
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 SHA256 is the file digest algorithm. The page notes that if /fd is not given, "the command generates an error" in current SDK builds.
  • /tr URL is an RFC 3161 time-stamp server and /td SHA256 the digest it should use; without /td the command "generates an error" when time-stamping.
  • /a picks the best certificate automatically instead of naming one.

Verify the result:

text
signtool verify /pa /v MyFile.exe

Why 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 .exe is unsigned.

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#

    QuoteReply
    Share
    Hacker NewsRedditLinkedInE-mail

    No replies yet