SignTool.exe (Sign Tool)
Sign Tool is a command-line tool that digitally signs files, verifies signatures in files, and time-stamps files.
This tool is automatically installed with Visual Studio. To run the tool, use the Developer Command Prompt (or the Visual Studio Command Prompt in Windows 7). For more information, see Visual Studio Command Prompt.
At the command prompt, type the following:
One of four commands (catdb, sign, Timestamp, or Verify) that specifies an operation to perform on a file. For a description of each command, see the next table.
An option that modifies a command. In addition to the global /q and /v options, each command supports a unique set of options.
The path to a file to sign.
The following commands are supported by Sign Tool. Each command is used with distinct sets of options, which are listed in their respective sections.
Adds a catalog file to, or removes it from, a catalog database. Catalog databases are used for automatic lookup of catalog files and are identified by GUID. For a list of the options supported by the catdb command, see catdb Command Options.
Digitally signs files. Digital signatures protect files from tampering, and enable users to verify the signer based on a signing certificate. For a list of the options supported by the sign command, see sign Command Options.
Time-stamps files. For a list of the options supported by the TimeStamp command, see TimeStamp Command Options.
Verifies the digital signature of files by determining whether the signing certificate was issued by a trusted authority, whether the signing certificate has been revoked, and, optionally, whether the signing certificate is valid for a specific policy. For a list of the options supported by the Verify command, see Verify Command Options.
The following options apply to all Sign Tool commands.
Displays no output if the command runs successfully, and displays minimal output if the command fails.
Displays verbose output regardless of whether the command runs successfully or fails, and displays warning messages.
Displays debugging information.
The following table lists the options that can be used with the catdb command.
Specifies that the default catalog database is updated. If neither the /d nor the /g option is used, Sign Tool updates the system component and driver database.
Specifies that the catalog database identified by the globally unique identifier GUID is updated.
Removes the specified catalogs from the catalog database. If this option is not specified, Sign Tool adds the specified catalogs to the catalog database.
Specifies that a unique name is automatically generated for the added catalog files. If necessary, the catalog files are renamed to prevent name conflicts with existing catalog files. If this option is not specified, Sign Tool overwrites any existing catalog that has the same name as the catalog being added.
The following table lists the options that can be used with the sign command.
Sign command option
Automatically selects the best signing certificate. Sign Tool will find all valid certificates that satisfy all specified conditions and select the one that is valid for the longest time. If this option is not present, Sign Tool expects to find only one valid signing certificate.
Adds an additional certificate from file to the signature block.
Appends this signature. If no primary signature is present, this signature is made the primary signature instead.
Specifies the Certificate Template Name (a Microsoft extension) for the signing certificate.
Specifies the cryptographic service provider (CSP) that contains the private key container.
Specifies a description of the signed content.
Specifies a Uniform Resource Locator (URL) for the expanded description of the signed content.
Specifies the signing certificate in a file. If the file is in Personal Information Exchange (PFX) format and protected by a password, use the /p option to specify the password. If the file does not contain private keys, use the /csp and /k options to specify the CSP and private key container name.
Specifies the file digest algorithm to use for creating file signatures. The default is SHA1.
Specifies the name of the issuer of the signing certificate. This value can be a substring of the entire issuer name.
Specifies the private key container name.
Specifies the name of the subject of the signing certificate. This value can be a substring of the entire subject name.
If supported, suppresses page hashes for executable files. The default is determined by the SIGNTOOL_PAGE_HASHES environment variable and by the wintrust.dll version. This option is ignored for non-PE files.
Specifies the password to use when opening a PFX file. (Use the /f option to specify a PFX file.)
Specifies that a Public Key Cryptography Standards (PKCS) #7 file is produced for each specified content file. PKCS #7 files are named path\filename.p7.
Specifies options for the signed PKCS #7 content. Set Value to "Embedded" to embed the signed content in the PKCS #7 file, or to "DetachedSignedData" to produce the signed data portion of a detached PKCS #7 file. If the /p7ce option is not used, the signed content is embedded by default.
Specifies the object identifier (OID) that identifies the signed PKCS #7 content.
If supported, generates page hashes for executable files.
Specifies the name of the subject of the root certificate that the signing certificate must chain to. This value may be a substring of the entire subject name of the root certificate.
Specifies the store to open when searching for the certificate. If this option is not specified, the My store is opened.
Specifies the SHA1 hash of the signing certificate. The SHA1 hash is commonly specified when multiple certificates satisfy the criteria specified by the remaining switches.
Specifies that a machine store, instead of a user store, is used.
Specifies the URL of the time stamp server. If this option (or /tr) is not present, the signed file will not be time stamped. A warning is generated if time stamping fails. This option cannot be used with the /tr option.
Used with the /tr option to request a digest algorithm used by the RFC 3161 time stamp server.
Specifies the URL of the RFC 3161 time stamp server. If this option (or /t) is not present, the signed file will not be time stamped. A warning is generated if time stamping fails. This option cannot be used with the /t option.
Specifies the enhanced key usage (EKU) that must be present in the signing certificate. The usage value can be specified by OID or string. The default usage is "Code Signing" (18.104.22.168.22.214.171.124.3).
Specifies usage of "Windows System Component Verification" (126.96.36.199.4.1.3188.8.131.52).
For usage examples, see Using SignTool to Sign a File.
The following table lists the options that can be used with the TimeStamp command.
Time stamps PKCS #7 files.
Specifies the URL of the time stamp server. The file being time stamped must have previously been signed. Either the /t or the /tr option is required.
Requests a digest algorithm used by the RFC 3161 time stamp server. /td is used with the /tr option.
Time stamps the signature at index.
Specifies the URL of the RFC 3161 time stamp server. The file being time stamped must have previously been signed. Either the /tr or the /t option is required.
For a usage example, see Adding Time Stamps to Previously Signed Files.
Specifies that all methods can be used to verify the file. First, the catalog databases are searched to determine whether the file is signed in a catalog. If the file is not signed in any catalog, Sign Tool attempts to verify the file's embedded signature. This option is recommended when verifying files that may or may not be signed in a catalog. Examples of these files include Windows files or drivers.
Finds the catalog by using the default catalog database.
Finds the catalog in the catalog database that is identified by the CatDBGUID.
Verifies all signatures in a file that includes multiple signatures.
Finds the catalog by using the system component (driver) catalog database.
Specifies the catalog file by name.
Specifies that Sign Tool should print the description and the description URL.
Verifies the signature at a specified position.
Specifies an optional hash algorithm to use when searching for a file in a catalog.
Specifies that verification should be performed with the kernel-mode driver signing policy.
Uses multiple verification semantics. This is the default behavior of a WinVerifyTrust call on Windows 8 and above.
Verifies the file by operating system version. Version has the following form: PlatformID:VerMajor.VerMinor.BuildNumber. PlatformID represents the underlying value of a PlatformID enumeration member.
Verifies PKCS #7 files. No existing policies are used for PKCS #7 validation. The signature is checked and a chain is built for the signing certificate.
Specifies that the Default Authenticode Verification Policy should be used. If the /pa option is not specified, Sign Tool uses the Windows Driver Verification Policy. This option cannot be used with the catdb options.
Specifies a verification policy by GUID. The PolicyGUID corresponds to the ActionID of the verification policy. This option cannot be used with the catdb options.
Specifies that Sign Tool should print and verify page hash values.
Specifies the name of the subject of the root certificate that the signing certificate must chain to. This value can be a substring of the entire subject name of the root certificate.
Specifies that a warning should be generated if the signature is not time stamped.
For usage examples, see Using SignTool to Verify a File Signature.
Sign Tool returns one of the following exit codes when it terminates.
Execution was successful.
Execution has failed.
Execution has completed with warnings.
The following command adds the catalog file MyCatalogFileName.cat to the system component and driver database. The /v option generates a unique name if necessary to prevent replacing an existing catalog file named MyCatalogFileName.cat.
signtool catdb /v /u MyCatalogFileName.cat
The following command signs a file automatically by using the best certificate.
signtool sign /a MyFile.exe
The following command digitally signs a file by using a certificate stored in a password-protected PFX file.
signtool sign /f MyCert.pfx /p MyPassword MyFile.exe
The following command digitally signs and time-stamps a file. The certificate used to sign the file is stored in a PFX file.
signtool sign /f MyCert.pfx /t HYPERLINK "http://timestamp.verisign.com/scripts/timstamp.dll" http://timestamp.verisign.com/scripts/timstamp.dll MyFile.exe
The following command signs a file by using a certificate located in the My store that has a subject name of My Company Certificate.
signtool sign /n "My Company Certificate" MyFile.exe
The following command signs an ActiveX control and provides information that is displayed by Internet Explorer when the user is prompted to install the control.
Signtool sign /f MyCert.pfx /d: "MyControl" /du http://www.example.com/MyControl/info.html MyControl.exe
The following command time-stamps a file that has already been digitally signed.
signtool timestamp /t HYPERLINK "http://timestamp.verisign.com/scripts/timstamp.dll" http://timestamp.verisign.com/scripts/timstamp.dll MyFile.exe
The following command verifies that a file has been signed.
signtool verify MyFile.exe
The following command verifies a system file that may be signed in a catalog.
signtool verify /a SystemFile.dll
The following command verifies a system file that is signed in a catalog named MyCatalog.cat.
signtool verify /c MyCatalog.cat SystemFile.dll