.Net 名 tool (sn.exe) Usage Details

Source: Internet
Author: User
-

The strong name tool helps you use strong name pairsProgramSet. Sn.exe provides options for key management, Signature generation, and signature verification.

Syntax format:
SN [-Quiet] [Option [parameter (s)]

Parameters and options

-C [CSP]
Set the default encryption service provider (CSP) to use a strong name signature. This setting applies to the entire computer. If the CSP name is not specified, sn.exe clears the current settings.

-D container
Deletes the specified key container from the strong name CSP.

-D Assembly1 Assembly2
Verify that the two sets have different signatures. This is often used as a check for using different keys to create signatures for the new Assembly.

-E Assembly OUTFILE
Extract the public key from assembly and store it in OUTFILE.

-H
Displays the command syntax and options of the tool.

-I infile container
Install the key pair from the infile in the specified key container. The key container is located in the CSP with a strong name.

-K [keysize] OUTFILE
Generate a new rsacryptoserviceprovider key of the specified size and write it to the specified file. Both the public key and private key are written into the file.
If you do not specify the key size and have installed Microsoft enhanced cryptographic provider, A 1,024-bit key is generated by default. Otherwise, a 512-bit key is generated.
If Microsoft enhanced cryptographic provider is installed, the keysize parameter supports the length of the key between 384-16,384 bits (8 bits in increments. If Microsoft base cryptographic provider is installed, the length of the 384-bit key to 512-bit (8-bit increment) is supported.

-M [Y | n]
Specify whether the key container is computer-specific or user-specific. If y is specified, the key container is computer-specific. If n is specified, the key container is user-specific.
If neither y nor N is specified, this option displays the current setting.

-O infile [OUTFILE]
Extract the public key from infile and store it in the. CSV file. Each byte of the public key is separated by a comma. This format is applicableSource codeIt is useful to reference the public key as an initialization array. If OUTFILE is not specified, this option places the output to the clipboard.

-P infile OUTFILE
Extract the public key from the key pair in infile and store it in OUTFILE. This public key can be used to sign the Assembly by using the/delaysign + and/Keyfile options of the Assembly Linker (al.exe. If the signature of the Assembly is delayed, only the public key is set during compilation, and the file reserves space for the signature added when the public key is known later.

-PC Container OUTFILE
Extract the public key from the key pair in the container and store it in OUTFILE.

-Q [uiet]
Specify quiet mode; cancel the display of successful messages.

-R [a] Assembly infile
Use the key pair in infile to re-sign the previously signed assembly or delay the signed assembly.
If-Ra is used, the hash of all files in the Assembly is recalculated.

-RC [a] Assembly container
Use the key pair in the container to re-sign the previously signed assembly or delay the signed assembly.
If-RCA is used, the hash of all files in the Assembly is recalculated.

-Rh assembly
Re-calculate the hash of all files in the Assembly.
 
-T [p] infile
Displays the mark of the public key stored in infile. The content of infile must be the public key previously generated from the key pair file using-P. Do not use the-T [p] Option to extract the tag directly from the key pair file.
Sn.exe uses the hash function in the public key to calculate the tag. To save space, the common language runtime stores the Public Key tag in the list when recording dependencies on strongly-named assemblies as part of a reference to another assembly. -In addition to the display tag, the TP option also displays the public key.
Note that this option does not verify the Assembly signature and should not be used to make trust decisions. This option only displays the raw Public Key tag data.

-T [p] Assembly
Displays the Assembly Public Key tag. Assembly must be the name of the file containing the Assembly List.
Sn.exe uses the hash function in the public key to calculate the tag. To save space, the common language runtime stores the Public Key tag in the list when recording dependencies on strongly-named assemblies as part of a reference to another assembly. -In addition to the display tag, the TP option also displays the public key.
Note that this option does not verify the Assembly signature and should not be used to make trust decisions. This option only displays the raw Public Key tag data.

 

 

-V assembly
Verify the strong name in assembly, where assembly is the file name that contains the Assembly List.

-VF assembly
Validate Strong names in assembly. Unlike the-V option,-VF enforces verification even if the-VR option is used to disable verification.

-VL
Lists the current settings for strong name verification on this computer.

-VR Assembly [userlist] [infile]
Register assembly to skip verification. Alternatively, you can specify a list of user names separated by commas. If infile is specified, verification is enabled, but the public key in infile is used for verification. You can specify the assembly in the form of *, strongname to register all the assembly with the specified strong name. Strongname should be specified as a string of hexadecimal numbers to represent the marked public key. See the-T and-T options to display the Public Key tag.

Warning
Use this option only during development. Adding an assembly to the skip verification list will result in a security vulnerability. If an assembly is added to the skip verification list, malicious assembly can hide its identity by using the fully qualified assembly name of the Assembly, the fully qualified assembly name consists of the Assembly name, version, culture, and public key tag. This allows the malicious assembly to skip verification.

-Vu assembly
Log out of assembly and do not skip verification. The same Assembly naming rules applied to-VR are also applied to-vu.

-VX
Removes all verification skipping items.

-?
Displays the command syntax and options of the tool.

Note:
All sn.exe options are case sensitive and must be fully typed as shown above to be recognized by this tool.
 
Remarks
The-R and-RC options are useful for delayed signature assembly. In this solution, only the public key is set during compilation and the signature is executed when the private key is known later.

Example

The following command creates a random key pair and stores it in keypair. SNK.
Sn-K keypair. SNK

The following command stores the key in keypair. SNK in the container mycontainer in the strong-name CSP.
Sn-I keypair. SNK mycontainer

The following command extracts the public key from keypair. SNK and stores it in publickey. SNK.
Sn-P keypair. SNK publickey. SNK

The following command displays the public key and the Public Key tag included in publickey. SNK.
Sn-TP publickey. SNK

The following command verifies the Assembly myasm. dll.
Sn-V myasm. dll

The following command deletes mycontainer from the default CSP.
Sn-D mycontainer

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.