How to Sign an EXE File
Follow this hands-on procedure to sign a Windows executable with Authenticode, add an RFC 3161 timestamp, verify the resulting signature, and prepare the exact EXE for release.
What you will do: prepare the final EXE, install or locate SignTool, identify the certificate and private key, sign the file, timestamp it, verify the signature, inspect the Windows signature details, and test the release artifact.
Before You Start
This guide assumes you are signing a Windows PE executable such as ExampleApp.exe. The signing operation should happen after the executable has passed your build and release tests. Signing is part of release packaging, not a substitute for testing the application itself.
.exe ready for releaseImportant: SignTool does not issue a trusted code signing identity. You must already have a suitable certificate and access to its matching private key. A self-signed certificate can be used for testing, but it does not provide the same public trust as a certificate issued by a publicly trusted CA.
Keep these paths as examples only. Replace them with the locations used by your build environment. The commands below use C:\Release\ExampleApp.exe, C:\Keys\codesigning.pfx, PFX_PASSWORD, and TIMESTAMP_URL as placeholders.
Prepare the Final EXE
Build the release version first. Complete the code changes, dependency updates, configuration changes, packaging, and tests before creating the signature. The file you sign should be the file you intend to distribute.
Do not plan to edit the binary after signing. If the release process replaces the EXE, patches its executable contents, or produces a different binary, treat the replacement as a new artifact that must be signed and verified again.
Get a Code Signing Certificate
If this is a production release, obtain a code signing certificate from a certificate authority that issues certificates appropriate for your software distribution requirements. The certificate identifies the publisher; the matching private key is what lets you create the signature.
For testing, you can use a development or self-signed certificate, but do not present that result as equivalent to a publicly trusted production signature. Before continuing, confirm that the certificate is valid for code signing and that you have access to its private key.
Do not continue with only a .cer or .crt file. Those files normally contain the public certificate. You also need the corresponding private key through a PFX, Windows certificate store, HSM, or supported remote signing provider.
Install or Locate SignTool
SignTool is part of the Windows SDK. Microsoft installs it under the SDK's Bin directory, with architecture-specific folders such as x64. Use the version appropriate for your build environment. Microsoft’s SignTool reference lists the supported commands and options, including the parameters used in the examples below.
signtool
If Windows cannot find the command, either run SignTool from its SDK directory or add the directory to the environment used by your build process. Confirm the executable exists before troubleshooting certificate problems.
Typical SDK location: C:\Program Files (x86)\Windows Kits\10\bin\<SDK-version>\x64\signtool.exe
Confirm the Certificate and Private Key
A certificate identifies the signer, but the signing operation requires access to the corresponding private key. The private key performs the cryptographic signing operation. A public certificate by itself cannot create the signature. A certificate file that contains only the public certificate is not enough.
PFX / P12
- Contains the certificate and private key material when exported for signing.
- May be protected by a password.
- Use SignTool's
/fand, when required,/poptions.
Windows Certificate Store
- The certificate is installed in a Windows certificate store.
- The private key remains associated with the installed certificate.
- Select the certificate with options such as
/nor/sha1.
For a production environment, do not copy a private key into the build workspace unless your security design explicitly permits it. Hardware-backed and remote signing models keep the private-key operation outside the normal build filesystem.
Choose How SignTool Will Access the Key
The command changes depending on where the certificate and private key are held. Choose the method that matches your setup and the access controls around the key.
| Key location | Typical SignTool approach | When to use it |
|---|---|---|
| Password-protected PFX | /f plus /p | Controlled local signing or a protected build environment |
| User certificate store | /n, /sha1, or automatic selection | Certificate already installed for the signing account |
| Machine certificate store | Store selection with /sm | Service or build-agent installation |
| HSM or remote service | Provider-specific integration | Private key should not be exportable to the build host |
Sign the EXE with SignTool
For a password-protected PFX, use the sign command. Current SignTool documentation requires the file digest algorithm to be specified, and Microsoft recommends SHA-256 for new signing operations.
signtool sign /fd SHA256 /f "C:\Keys\codesigning.pfx" /p "PFX_PASSWORD" "C:\Release\ExampleApp.exe"
signStarts the file-signing operation./fd SHA256Uses SHA-256 for the file digest./fPoints SignTool to the certificate file./pSupplies the PFX password when required.ExampleApp.exeIdentifies the exact executable being signed.The signing operation hashes the relevant PE image data and uses the private key to create the signature. The certificate and signature are embedded into the executable's certificate table. The application code is not replaced by the certificate.
For a certificate already available in the Windows store, a typical selection command is:
signtool sign /fd SHA256 /n "Example Company" "C:\Release\ExampleApp.exe"
When several certificates could match, select the intended certificate explicitly rather than relying on an ambiguous match.
Add an RFC 3161 Timestamp
A trusted timestamp records evidence associated with when the signature was made. For current Authenticode signing, use an RFC 3161 timestamp service and specify the timestamp digest algorithm. The separate timestamping step should be checked to confirm that the returned token is embedded in the signature.
signtool sign /fd SHA256 /tr "TIMESTAMP_URL" /td SHA256 /f "C:\Keys\codesigning.pfx" /p "PFX_PASSWORD" "C:\Release\ExampleApp.exe"
The /tr option identifies the RFC 3161 timestamp service, while /td SHA256 specifies the digest algorithm used for the timestamp. Microsoft’s Authenticode timestamping documentation describes the timestamping workflow and the role of RFC 3161 timestamps in signed software.
After timestamping, inspect the signature to confirm that the timestamp is actually present. Do not assume a successful signing command means the timestamp was successfully embedded.
Verify the Signed EXE with SignTool
Verification is a separate operation from signing. Run it against the exact file that you intend to distribute. For platform-specific checks, follow the Windows signature verification procedure.
signtool verify /pa /v "C:\Release\ExampleApp.exe"
The /pa option uses the Default Authentication Verification Policy rather than the driver verification policy, while /v provides detailed output. A successful command evaluates the signature, certificate chain, and trust under the selected policy. Microsoft’s SignTool verification documentation explains how to verify a file signature with these options.
Inspect the Signature in Windows
Use Windows Explorer as a second check. This confirms what an end user can inspect through the normal file properties interface.
Review the signer name, signature status, certificate details, certification path, and timestamp information. If Windows reports that the digital signature is not valid, stop the release process and investigate before distribution.
Release check: The file shown in Explorer should be the same file that passed your SignTool verification command. Verify the final copy from the release directory, not an earlier build output.
Understand What Changes After Signing
Signing does not make an EXE immutable. It creates a cryptographic relationship between the signed PE image and the signature. If data covered by the Authenticode image hash is changed afterward, verification can fail because the calculated hash no longer matches the signed hash.
Do not patch the executable, replace embedded resources, rebuild it, or otherwise alter the signed artifact after signing unless you intentionally sign and verify the resulting file again. The Microsoft PE format specification explains the Portable Executable structure, including the certificate table that stores Authenticode signature data.
Test the Exact Signed Artifact
Launch and test the signed EXE that will actually ship. This catches release-pipeline mistakes where a developer signs one file but packages another.
| Check | What to confirm |
|---|---|
| File identity | Filename, version, architecture, and build output match the intended release. |
| Signature | SignTool verification succeeds for the final file. |
| Publisher | The signer shown by Windows is the expected publisher. |
| Timestamp | The signature contains the expected trusted timestamp evidence. |
| Application behavior | The signed executable starts and performs the same release tests as the unsigned build. |
Using a PFX File Safely
A PFX or PKCS #12 file can package the signing certificate together with its private key. This makes local signing straightforward, but it also creates a sensitive credential that must be protected.
Do not commit a PFX file or its password to source control. Do not place it in an unrestricted build directory. In automated environments, protect both the credential and the mechanism that can invoke the private-key operation.
Choose a Signing Setup That Fits Your Release Process
Compare code signing options for local signing, protected key storage, and software distribution before choosing the setup for your release workflow.
Explore the Code Signing Buying GuideWhen the Private Key Is Hardware-Protected or Remote
Organizations that need stronger key custody may use an HSM or a remote signing service. In that model, the build system submits signing material or a digest to a controlled signing boundary rather than receiving an exportable private key.
The exact SignTool integration depends on the certificate provider, cryptographic provider, and signing service. Do not assume a PFX command is interchangeable with an HSM or cloud signing workflow.
Automate Signing in CI/CD
In a release pipeline, signing should be a controlled stage after the build artifact is finalized. The pipeline should not simply call SignTool and publish whatever comes out. It should establish a clear boundary between artifact creation, signing, verification, and release.
Common Problems and What to Check
| Problem | First checks |
|---|---|
| “SignTool is not recognized” | Confirm the Windows SDK is installed and locate the correct signtool.exe architecture. |
| Certificate not found | Check the PFX path or Windows certificate store, then confirm the signing account can access the private key. |
| Private key unavailable | Confirm the certificate is associated with its private key and that the current account or provider can use it. |
| Timestamp failure | Check the RFC 3161 URL, network access, proxy rules, and timestamp digest option. |
| Verification fails after packaging | Compare the packaged EXE with the file that was signed. A post-signing modification or replacement may have occurred. |
| Unknown Publisher | Inspect the embedded certificate, certificate chain, trust status, and the publisher identity shown by Windows. |
| Works locally but fails in CI | Compare certificate-store access, private-key permissions, SDK version, environment variables, and network access to the timestamp service. |
Complete Example: Sign ExampleApp.exe
Assume the final release file is C:\Release\ExampleApp.exe, the signing certificate is stored in C:\Keys\codesigning.pfx, and the PFX requires a password. Replace the placeholders with your actual values.
signtool sign /fd SHA256 /tr "TIMESTAMP_URL" /td SHA256 /f "C:\Keys\codesigning.pfx" /p "PFX_PASSWORD" "C:\Release\ExampleApp.exe"
signtool verify /pa /v "C:\Release\ExampleApp.exe"
Do not replace the EXE after verification. If your packaging system copies a different binary into the distribution folder, verify that final copy again before publishing.
Final Release Checklist
Related Signing Workflows
EXE signing is one implementation of software signing. The underlying trust model changes across platforms, so use the workflow that matches the artifact you are actually distributing.
Frequently Asked Questions
Can I sign an EXE without a code signing certificate?
You can create test signatures with development or self-signed certificates, but that is different from using a publicly trusted code signing identity for software distribution. The certificate trust model determines how Windows and users evaluate the signer.
Does signing encrypt the EXE?
No. Authenticode signing provides a digital signature and signer identity. It does not encrypt the executable or hide its code.
Does the private key get embedded into the EXE?
No. The private key performs the signing operation and should remain protected. The resulting executable contains the signature and certificate information needed for verification, not the signer's private key.
Should I timestamp every production EXE?
For production software, a trusted timestamp is an important part of the release-signing process because it provides evidence associated with the signing time. Use an RFC 3161 timestamp service and verify that the timestamp is actually present.
Can I modify an EXE after signing?
You should treat the signed EXE as final. Changes to data covered by the Authenticode image hash can invalidate the signature. If the release binary changes, sign and verify the resulting artifact again.
What should CI/CD do if signature verification fails?
The release should stop. Investigate the exact artifact, certificate access, signing command, timestamp response, and any post-signing packaging step before allowing the release to continue.
Sign the Final Artifact, Then Verify It
A reliable EXE signing process has a clear boundary: finish the binary first, perform the private-key operation, add trusted time evidence, verify the signature, and release the exact file that passed those checks.
Technical references: Microsoft SignTool documentation, Microsoft Authenticode timestamp guidance, and the Microsoft Portable Executable format specification.
Explore Code Signing Certificates