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.

01
Final EXEBuild and freeze the release artifact
→
02
SignToolCalculate the signing digest
→
03
Certificate + private keyCreate the Authenticode signature
→
04
RFC 3161 timestampBind signing time to a trusted timestamp
→
05
Signed EXEVerify before distribution
✓

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.

A final .exe ready for release
A production code signing certificate (or a test/development certificate for non-production use)
Access to the matching private key
Windows SDK with SignTool
An RFC 3161 timestamp service
Permission to use the certificate/key

Important: 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.

1

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.

Release boundary
Source→Build→Test→Package→Final EXE→Sign→Release

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.

2

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.

What you need before SignTool can sign
Certificatepublisher identity
+
Private keysigning operation
+
SignToolcreates Authenticode signature

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.

3

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.

Command Prompt
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

4

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 /f and, when required, /p options.

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 /n or /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.

5

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 locationTypical SignTool approachWhen to use it
Password-protected PFX/f plus /pControlled local signing or a protected build environment
User certificate store/n, /sha1, or automatic selectionCertificate already installed for the signing account
Machine certificate storeStore selection with /smService or build-agent installation
HSM or remote serviceProvider-specific integrationPrivate key should not be exportable to the build host
6

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.

Sign with a PFX
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.

What the signing operation does
EXE imagerelease bytes
→
SHA-256 digestintegrity value
→
Private-key operationdigital signature

For a certificate already available in the Windows store, a typical selection command is:

Use a certificate from the store
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.

7

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.

Sign and timestamp in one operation
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.

Timestamp relationship
Code signaturecreated with private key
→
RFC 3161 servicetrusted time evidence
→
Timestamped signatureembedded in signed artifact

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.

8

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.

Verify the Authenticode signature
signtool verify /pa /v "C:\Release\ExampleApp.exe"
SignatureIs an embedded signature present and valid?
SignerWhich certificate identifies the signer?
ChainCan Windows build a trusted certificate chain?
IntegrityDoes the signed file still match its signed state?

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.

9

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.

Right-click EXE→Properties→Digital Signatures→Select signature→Details

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.

10

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.

Safe release sequence
Build→Modify→Test→Package→Sign→Timestamp→Verify→Release

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.

11

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.

CheckWhat to confirm
File identityFilename, version, architecture, and build output match the intended release.
SignatureSignTool verification succeeds for the final file.
PublisherThe signer shown by Windows is the expected publisher.
TimestampThe signature contains the expected trusted timestamp evidence.
Application behaviorThe 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.

PFX signing boundary
PFX filecertificate + private key
→
Protected signing environmentpassword / access control
→
Signed EXEprivate key does not become part of the EXE

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 Guide

When 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.

Remote signing boundary
Build agentproduces final EXE
→
Signing servicepolicy + authentication
→
Protected keyHSM / remote custody

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.

CI/CD release gate
Build→Unit tests→Package EXE→Sign→Timestamp→Verify→Security checks→Publish
Keep signing credentials outside source control
Restrict which jobs can invoke signing
Sign only the final release artifact
Fail the release if verification fails
Record signer and certificate information
Verify the exact artifact uploaded for distribution

Common Problems and What to Check

ProblemFirst checks
“SignTool is not recognized”Confirm the Windows SDK is installed and locate the correct signtool.exe architecture.
Certificate not foundCheck the PFX path or Windows certificate store, then confirm the signing account can access the private key.
Private key unavailableConfirm the certificate is associated with its private key and that the current account or provider can use it.
Timestamp failureCheck the RFC 3161 URL, network access, proxy rules, and timestamp digest option.
Verification fails after packagingCompare the packaged EXE with the file that was signed. A post-signing modification or replacement may have occurred.
Unknown PublisherInspect the embedded certificate, certificate chain, trust status, and the publisher identity shown by Windows.
Works locally but fails in CICompare 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.

1. Sign and timestamp
signtool sign /fd SHA256 /tr "TIMESTAMP_URL" /td SHA256 /f "C:\Keys\codesigning.pfx" /p "PFX_PASSWORD" "C:\Release\ExampleApp.exe"
2. Verify
signtool verify /pa /v "C:\Release\ExampleApp.exe"
Command succeeds→Verify succeeds→Check Windows Digital Signatures→Run release tests→Publish exact file

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

Final EXE build is complete
Application tests passed
Correct signing certificate selected
Private key is accessible through the approved method
SHA-256 file digest specified
RFC 3161 timestamp added
SignTool verification succeeds
Windows Digital Signatures status is valid
Certificate chain and publisher are expected
Exact release EXE was tested
No post-signing modification occurred
Final distributed copy was verified

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