|
| 1 | +--- |
| 2 | +title: Sign CLI reference for VSIX packages |
| 3 | +description: The Sign CLI command can sign VSIX packages using certificates from PFX, Windows Certificate Manager (WCM), or Cryptographic Service Providers (CSP). |
| 4 | +ms.topic: reference |
| 5 | +helpviewer_keywords: |
| 6 | +- signature |
| 7 | +- signing |
| 8 | +- sign |
| 9 | +- pfx |
| 10 | +- sha256 |
| 11 | +- authenticode |
| 12 | +- vsix |
| 13 | +- packages |
| 14 | +- dotnet |
| 15 | +author: javierdlg |
| 16 | +ms.author: maiak |
| 17 | +manager: mijacobs |
| 18 | +ms.subservice: extensibility-integration |
| 19 | +ms.date: 04/11/2024 |
| 20 | +--- |
| 21 | + |
| 22 | +# Sign CLI Reference for VSIX Packages |
| 23 | + |
| 24 | +`sign` - Dotnet tool used to sign files and containers using PFX, CER, or P7B certificates on disk or from Windows Certificate Manager (WCM), Cryptographic Service Providers (CSP), or Azure Key Vault. |
| 25 | + |
| 26 | +> [!IMPORTANT] |
| 27 | +> Sign CLI only supports `SHA-256`, `SHA-384`, and `SHA-512` as valid fingerprint algorithms. You can use PowerShell to get fingerprints using: `Get-FileHash -Algorithm SHA256 <path to .cer file> | Format-Table -AutoSize` |
| 28 | +
|
| 29 | +## Synopsis |
| 30 | + |
| 31 | +```dotnetcli |
| 32 | +sign code certificate-store [<PATH(s)>] |
| 33 | + [-cf|--certificate-file <PATH>] |
| 34 | + [-p|--password <PASSWORD>] |
| 35 | + [-cfp|--certificate-fingerprint <SHA>] |
| 36 | + [-csp|--crypto-service-provider <CSPNAME>] |
| 37 | + [-k|--key-container <HASHALGORITHM>] |
| 38 | + [-km|--use-machine-key-container] |
| 39 | + [-d|--description <DESCRIPTION>] |
| 40 | + [-u|--descriptionUrl <URL>] |
| 41 | + [-fd|--file-digest <DIGEST>] |
| 42 | + [-t|--timestamp-url <URL>] |
| 43 | + [-tr|--timestamp-rfc3161 <URL>] |
| 44 | + [-td|--timestamp-digest <DIGEST>] |
| 45 | + [-o|--output <PATH>] |
| 46 | + [-b|--base-directory <wORKINGDIRECTORY>] |
| 47 | + [-f|--force] |
| 48 | + [-m|--max-concurrency <MAXCONCURRENCY>] |
| 49 | + [-fl|--filelist <FILELISTPATH>] |
| 50 | +
|
| 51 | +sign code certificate-store -h|--help |
| 52 | +``` |
| 53 | + |
| 54 | +## Description |
| 55 | + |
| 56 | +`Sign CLI` is a Dotnet tool that recursively signs files and containers with a certificate and private. The certificate and private key can be obtained from either a file (PFX, P7B, CER) or from a certificate installed in a certificate store by providing a `SHA-256`, `SHA-384`, or `SHA-512` fingerprint. USB keys can be accessed using a [Cryptographic Service Provider](/windows/win32/seccrypto/cryptographic-service-providers) (CSP) implemented by the manufacturer and accessed from the certificate store. |
| 57 | + |
| 58 | +## Installation |
| 59 | +Install Sign CLI globally using `dotnet tool install sign --version <version> --global`, where `<version>` is the latest available version under [Sign (nuget.org)](https://www.nuget.org/packages/sign). |
| 60 | + |
| 61 | +### Offline Installation of Sign CLI |
| 62 | +For isolated environments you can download a Sign CLI NuGet package and install it using: |
| 63 | + |
| 64 | +```dotnetcli |
| 65 | +dotnet tool install --global --add-source <path-to-folder> <tool-name> --version <version> |
| 66 | +``` |
| 67 | + |
| 68 | +## Arguments |
| 69 | + |
| 70 | +- **`VSIX-paths(s)`** |
| 71 | + |
| 72 | + Specifies the path(s) to the VSIX package to be signed. |
| 73 | + |
| 74 | +## Options |
| 75 | + |
| 76 | +- **`-cf|--certificate-file <PATH>`** |
| 77 | + |
| 78 | + PFX, P7B, or CER file containing a certificate and potentially a private key. |
| 79 | + |
| 80 | +- **`-p|--password <PASSWORD>`** |
| 81 | + |
| 82 | + Optional password for certificate file. |
| 83 | + |
| 84 | +- **`-cfp|--certificate-fingerprint <SHA>`** |
| 85 | + |
| 86 | + SHA-256, SHA-384, or SHA-512 fingerprint used to identify a certificate before signing. |
| 87 | + |
| 88 | +- **`-csp|--crypto-service-provider <CSP NAME>`** |
| 89 | + |
| 90 | + Cryptographic Service Provider containing a private key. |
| 91 | + |
| 92 | +- **`-k|--key-container <CONTAINER NAME>]`** |
| 93 | + |
| 94 | + Private key container name. |
| 95 | + |
| 96 | +- **`-km|--use-machine-key-container]`** |
| 97 | + |
| 98 | + Use a machine-level private key container instead of the default user-level container. |
| 99 | + |
| 100 | +- **`-d|--description <DESCRIPTION>`** |
| 101 | + |
| 102 | + Description of the signing certificate. |
| 103 | + |
| 104 | +- **`-u|--descriptionUrl <URL>`** |
| 105 | + |
| 106 | + Description Url of the signing certificate. |
| 107 | + |
| 108 | +- **`-fd | --file-digest <DIGEST>`** |
| 109 | + |
| 110 | + Digest algorithm to hash the file with. |
| 111 | + |
| 112 | +- **`-t|--timestamp-url <URL>`** |
| 113 | + |
| 114 | + RFC 3161 timestamp server URL. [default: http://timestamp.acs.microsoft.com/] |
| 115 | + |
| 116 | +- **`-tr | --timestamp-rfc3161 <URL>`** |
| 117 | + |
| 118 | + Specifies the RFC 3161 timestamp server's URL. |
| 119 | + |
| 120 | +- **`-td|--timestamp-digest <DIGEST>`** |
| 121 | + |
| 122 | + Used with `-tr` switch to request a digest algorithm used by the RFC 3161 timestamp server. |
| 123 | + |
| 124 | +- **`-o|--output <PATH>`** |
| 125 | + |
| 126 | + The output file or folder if multiple files are specified. If omitted, input is overwritten. |
| 127 | + |
| 128 | +- **`-b|--base-directory <PATH>`** |
| 129 | + |
| 130 | + Base directory for files to override the working directory. |
| 131 | + |
| 132 | +- **`--f|--force`** |
| 133 | + |
| 134 | + Overwrites a signature if it exists. |
| 135 | + |
| 136 | +- **`-m|--max-concurrency <MAXCONCURRENCY>`** |
| 137 | + |
| 138 | + Maximum concurrency (default is 4) |
| 139 | + |
| 140 | +- **`-fl | --filelist <PATH>`** |
| 141 | + |
| 142 | + Path to file containing paths of files to sign or to exclude from signing within the container. |
| 143 | + |
| 144 | +- **`-?|-h|--help`** |
| 145 | + |
| 146 | + Prints a description of how to use the command. |
| 147 | + |
| 148 | +## Examples |
| 149 | + |
| 150 | +- Sign *contoso.vsix* with a certificate imported to the **user** certificate store: |
| 151 | + |
| 152 | + ```dotnetcli |
| 153 | + sign contoso.vsix -cfp 24D589...FB9523B36E -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 154 | + ``` |
| 155 | + |
| 156 | +- Sign *contoso.vsix* with certificate *cert.pfx* (not password protected) using a SHA-512 fingerprint: |
| 157 | + |
| 158 | + ```dotnetcli |
| 159 | + sign contoso.vsix -cfp A87A6F...894559B981 -cfpa sha512 -cf D:\certificates\cert.pfx -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 160 | + ``` |
| 161 | + |
| 162 | +- Sign *contoso.vsix* with certificate *cert.pfx* (password protected): |
| 163 | + |
| 164 | + ```dotnetcli |
| 165 | + sign contoso.vsix -s 24D58920B2D24D00A7DF07FB9523B36E -cf cert.pfx -p <password> -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 166 | + ``` |
| 167 | + |
| 168 | +- Sign multiple VSIX packages - *contoso.vsix* and *all .vsix files in the directory specified* with certificate *cert.pfx* (not password protected): |
| 169 | + |
| 170 | + ```dotnetcli |
| 171 | + sign *.vsix -s 24D58920B2D24D00A7DF07FB9523B36E -cf cert.pfx -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 172 | + ``` |
| 173 | + |
| 174 | +- Sign *contoso.vsix* with a certificate stored in a secure USB drive. |
| 175 | + |
| 176 | + ```dotnetcli |
| 177 | + sign contoso.vsix -s 24D58920B2D24D00A7DF07FB9523B36E -csp "Microsoft Software Key Storage Provider" -k "NuGetSigning 0B2D249223B36D00A7DF07FB95E24D58" -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 178 | + ``` |
| 179 | + |
| 180 | +- Sign *contoso.vsix* with a certificate stored in a secure USB drive and accessed from the **machine** certificate store (-km option). |
| 181 | + |
| 182 | + ```dotnetcli |
| 183 | + sign contoso.vsix -s 24D58920B2D24D00A7DF07FB9523B36E -csp "Microsoft Software Key Storage Provider" -k "NuGetSigning 0B2D249223B36D00A7DF07FB95E24D58" -km -d "Constoso VSIX Signature" -u "http://www.contoso.com" |
| 184 | + ``` |
| 185 | + |
| 186 | + > [!NOTE] |
| 187 | + > When `-k` option isn't provided, the tool checks all containers in the provided CSP for a matching SHA fingerprint certificate. |
| 188 | +
|
| 189 | +- Sign *contoso.vsix* with a certificate stored in a secure USB drive specifying file digest algorithm (-fd), timestamp server (-t), and a custom output path (-o) for the signed VSIX. |
| 190 | + |
| 191 | + ```dotnetcli |
| 192 | + sign contoso.vsix -s 24D58920B2D24D00A7DF07FB9523B36E -csp "Microsoft Software Key Storage Provider" -k "NuGetSigning 0B2D249223B36D00A7DF07FB95E24D58" -d "Constoso VSIX Signature" -u "http://www.contoso.com" -t "http://timestamp.acs.microsoft.com/" -fd sha256 -o "ContosoSigned.vsix" |
| 193 | + ``` |
0 commit comments