Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use SignTool to digitally sign and time stamp the executable artifacts that your application builds, installs, downloads, or runs. These artifacts can include executable files, DLLs, installers, scripts, modules, plug-ins, helper tools, update components, uninstallers, and catalog files. Signing lets Windows and customers verify the publisher and detect changes made after signing.
Sign every supported executable artifact instead of signing only the primary executable or installer. For scripts and other files that don't contain PE version resources, add authenticated metadata so that application-control systems can identify the file by its name, product, and version.
Prerequisites
- SignTool from the Windows SDK.
- A code-signing certificate and access to its private key. Keep private keys in a protected certificate store, hardware security module, or managed signing service.
- An RFC 3161 time stamp service if signatures must remain verifiable after the signing certificate expires.
- Windows 11, version 24H2 SDK (build 10.0.26100.0; SDK build tools package version 10.0.26100.1) or later for the signed file metadata workflow for scripts and non-PE files, including when you use
/d. An older SignTool recognizing/disn't sufficient for this workflow.
Sign and time stamp a file
The following procedure automatically selects an eligible code-signing certificate from the current user's My certificate store and applies an RFC 3161 time stamp.
Open a command prompt where
signtool.exeis available.Sign the file by using SHA256 for the file digest and time stamp digest:
signtool sign /a /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 MyApplication.exeVerify the signature by using the default Authenticode verification policy:
signtool verify /pa /v MyApplication.exe
SignTool returns exit code 0 for success, 1 for failure, and 2 when the operation completes with warnings. Treat warnings as failures in release automation unless the warning is explicitly reviewed and accepted.
Select a signing certificate
Choose one certificate-selection method for each signing operation.
Select a certificate automatically
Use /a when the certificate store contains only certificates that are appropriate for the release:
signtool sign /a /fd SHA256 MyApplication.exe
Select a certificate by subject name
Use /n to select a certificate from the current user's My store by subject name:
signtool sign /n "Contoso Software" /fd SHA256 MyApplication.exe
Use /sm to search the local computer certificate store instead:
signtool sign /sm /n "Contoso Software" /fd SHA256 MyApplication.exe
Select a certificate by SHA1 thumbprint
Use /sha1 when multiple certificates have similar subject names:
signtool sign /sha1 certificate-thumbprint /fd SHA256 MyApplication.exe
Use a certificate file
Use /f to specify a PFX file:
signtool sign /f MySigningCertificate.pfx /fd SHA256 MyApplication.exe
If the PFX file has a password, /p supplies it to SignTool. Avoid exposing passwords in command history, logs, response files, or build arguments. Prefer a protected certificate store, hardware-backed key, or managed signing service for production signing.
Use a hardware-backed private key
If the certificate is installed and its private key is managed by a cryptographic provider, select the certificate from the store:
signtool sign /n "Contoso Hardware-Protected Certificate" /fd SHA256 MyApplication.exe
If the certificate file doesn't contain the private key, use /csp and /kc to specify the cryptographic service provider and private key container:
signtool sign /f ContosoSigning.cer /csp "Contoso Cryptographic Provider" /kc "ContosoSigningKey" /fd SHA256 MyApplication.exe
Sign scripts and non-PE files
SignTool uses the SIP registered for a file type to create an embedded signature. For scripts and other non-PE files, add authenticated metadata to provide file identity and version information that would otherwise come from PE version resources.
For the complete procedure and metadata recommendations, see Sign scripts and non-PE files with SignTool.
Sign and verify a catalog
A signed catalog can protect a collection of files without modifying each file. Catalogs are useful when files don't support embedded signatures or when an existing application can't be rebuilt to add signatures. The catalog must be regenerated and signed whenever a covered file changes.
Create a catalog that contains the hashes of the files. For more information, see MakeCat.
Sign and time stamp the catalog:
signtool sign /a /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 MyApplication.catVerify the catalog signature:
signtool verify /pa /v MyApplication.catVerify a file against the signed catalog:
signtool verify /pa /c MyApplication.cat MyScript.ps1
Catalog trust also depends on certificate trust and how the catalog is registered or deployed on the destination device. A catalog signature isn't a universal replacement for embedded signing on unmanaged devices.
Automate signing with a response file
Response files keep long SignTool commands consistent across build and release jobs. Don't store passwords or other secrets in a response file.
Create a file named
signing-commands.txtthat contains one argument per line:sign /n "Contoso Software" /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 MyApplication.exe verify /pa /v MyApplication.exeRun the commands:
signtool @signing-commands.txt