C # in a Nutshell, Second Edition
| Sn.exe | Strong Name Utility |
Synopsis
sn options
Description
Verifies assemblies and their key information. Also generates key files and manages Cryptographic Service Provider (CSP) containers, which provide a layer of abstraction over key storage and management. CSPs are enumerated in the HKLM\SOFTWARE\Microsoft\Cryptography\Defaults\Provider registry key. See GacUtil.exe for an example of signing an assembly.
Examples
Create a new key-pair:
C:\home> sn -k mykey.snk Microsoft (R) .NET Framework Strong Name Utility Version 1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. Key pair written to mykey.snk
Add that key-pair to a container:
C:\home> sn -i mykey.snk MyContainer Microsoft (R) .NET Framework Strong Name Utility Version 1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. Key pair installed into 'MyContainer'
Extract the public key from the key in the container:
C:\home> sn -pc MyContainer pubkey.out Microsoft (R) .NET Framework Strong Name Utility Version 1.1.4322.573 Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. Public key written to pubkey.out
Options
- -? , help
-
Displays usage information and exits.
- -c [ csp ]
-
Sets the default CSP for your machine. With no arguments, resets the CSP to the default.
- -d container
-
Deletes the specified key container.
- -D assembly1assembly2
-
Compares two assemblies and verifies that they differ only by signature.
- -e assemblyfile
-
Extracts an assembly's public key into file .
- -i filecontainer
-
Installs a key-pair from file in the container.
- -k file
-
Generates a new key-pair and stores it in file .
- -m [yn]
-
With y , specifies that key containers are machine-specific. With n , specifies that they are user -specific . With no arguments, displays the current settings.
- -o keyfile [ csvfile ]
-
Converts a public key to comma-separated value (CSV) format and stores it in the csvfile . If csvfile is not specified, stores the data in the clipboard.
- -p infileoutfile
-
Extracts the public key from infile and stores it in outfile . Use the extracted public key for delay signing (see Al.exe ).
- -pc containerfile
-
Extracts the public key from the key-pair that is stored in the container. The public key is stored in file .
- -q
-
Suppresses display of success messages.
- -R assembly file
-
Re-signs a previously signed (or delay-signed) assembly.
- -Rc assemblycontainer
-
Re-signs a previously signed (or delay-signed) assembly using the key-pair in the specified container.
- -t[p] file
-
Displays a public key's token ( -t ) or the token and public key ( -tp ). The file must be generated with -p .
- -T[p] assembly
-
Displays an assembly's public key token ( -T ) or the token and public key ( -Tp ).
- -v[f] assembly
-
Verifies an assembly's strong name. Use f to force verification even if you have disabled it with -Vr .
- -Vl
-
Lists the machine's current settings for strong name verification.
- -Vr assembly [ userlist ]
-
Registers the assembly for verification skipping. You can optionally supply a list of users that this applies to.
- -Vu assembly
-
Unregisters the assembly for verification skipping.
- -Vx
-
Unregisters all verification skipping entries.
See Also
Al.exe , GacUtil.exe