How To Delay Sign an Assembly in .NET 2.0
From Guidance ShareJump to navigationJump to search
J.D. Meier, Alex Mackman, Blaine Wastell, Prashant Bansode, Chaitanya Bijwe
Summary of Steps
- Step 1. Create a public Key File for Delay Signing
- Step 2. Delay sign your assembly
Step 1. Create a public Key File for Delay Signing
When you use delay signing, distribute your public key in a .snk file that just contains the public key. Then, use the -keyfile compiler switch while you delay–sign the assemblies, or continue to use the AssemblyKeyFile attribute if you have existing .NET 1.x code that uses this attribute.
The signing authority performs the following procedure to create a public key file that developers can use to delay sign their assemblies.
Creating a Public Key File for Delay Signing
To create a public key file for delay signing
- Create a key pair for your organization.sn.exe -k keypair.snk
- Extract the public key from the key pair file. sn -p keypair.snk publickey.snk
- Protect Keypair.snk, which contains both the private and public keys. For example, put it on a compact disc or other hardware device, such as a smart card, and physically secure it.
- Make Publickey.snk available to all developers. For example, put it on a network share.
Step 2. Delay Sign Your Assembly
This procedure is performed by developers.
Delay Signing an Assembly
To delay sign an assembly
- In Visual Studio .NET 2005, display the project properties.
- Click the Signing tab, and select the Sign the assembly and Delay sign only check boxes.
- In the Choose a strong name key file: drop-down box, select <Browse…>.
- In the file selection dialog box, browse to the public key (.snk) and click OK.
- Build your assembly. The complier will build a strong named assembly signed using the public key from the selected key pair (.snk) file. Note A delay signed project will not run and cannot be debugged. You can, however, use the Strong Name tool (Sn.exe) with the -Vr option to skip verification during development.
- The delay signing process and the absence of an assembly signature means that the assembly will fail verification at load time. To work around this, use the following commands on development and test computers.
- To disable verification for a specific assembly, use the following command.
- To disable verification for all assemblies with a particular public key, use the following command.
- To extract the public key and key token (a truncated hash of the public key), use the following command.
- To fully complete the signing process and create a digital signature to make the assembly tamper proof, execute the following command. This requires the private key, and as a result the operation is normally performed as part of the formal build/release process. The following command uses key pair contained in the Keypair.snk file to re-sign an assembly called Assembly.dll with a strong name. sn -R assembly.dll keypair.snk Done