machineKey Element (ASP.NET Settings Schema)
Configures algorithms and keys to use for encryption, decryption, and validation of forms-authentication data and view-state data, and for out-of-process session state identification.
system.web Element (ASP.NET Settings Schema)
machineKey Element (ASP.NET Settings Schema)
<machineKey
validationKey="AutoGenerate,IsolateApps" [String]
decryptionKey="AutoGenerate,IsolateApps" [String]
validation="HMACSHA256" [SHA1 | MD5 | 3DES | AES | HMACSHA256 |
HMACSHA384 | HMACSHA512 | alg:algorithm_name]
decryption="Auto" [Auto | DES | 3DES | AES | alg:algorithm_name]
/>
The following sections describe attributes, child elements, and parent elements.
Attributes
|
Attribute |
Description |
|---|---|
|
decryption |
Optional String attribute. Specifies the algorithm that is used for encrypting and decrypting forms-authentication data. This attribute can have one of the following values:
|
|
decryptionKey |
Required String attribute. Specifies the key that is used to encrypt and decrypt data or the process by which the key is generated. This attribute is used for forms-authentication encryption and decryption, and for view-state encryption and decryption when view state is encrypted. This attribute can have one of the following values:
For more information, see DecryptionKey. |
|
validation |
Required MachineKeyValidation attribute. Specifies the hash algorithm that is used to validate data. By default, view state is transmitted as a base-64 encoded string. Although at first glance encoded data is unintelligible, base-64 encoding provides no security because it is easily decoded. If you store sensitive data in view state, you can specify that ASP.NET encrypts view-state data in addition to validating it. You can specify view-state encryption for all pages of your Web application or for selected pages. For information about this option, see ViewStateEncryptionMode and RegisterRequiresViewStateEncryption. If you want to use view-state encryption, set this attribute to AES. In that case, the value of decryptionKey will be used to encrypt view-state data, and ASP.NET will use the HMACSHA1 hash algorithm for data validation. This attribute can have one of the following values.
|
|
validationKey |
Required String attribute. Specifies the key that is used to validate data, or the process by which it is generated. The validationKey value is also used to generate out-of-process, application-specific session IDs to ensure that session-state variables are isolated between sessions. This attribute can have one of the following values:
For more information, see ValidationKey. |
Child Elements
None.
Parent Elements
|
Element |
Description |
|---|---|
|
configuration |
Specifies the required root element in every configuration file that is used by the common language runtime and in .NET Framework applications. |
|
system.web |
Specifies the root element for the ASP.NET configuration settings in a configuration file and contains configuration elements that configure ASP.NET Web applications and control how applications behave. |
The following code example demonstrates how to set both the validationKey and decryptionKey attributes to AutoGenerate. The isolateApps value is specified to generate unique keys for each application on the server.
<machineKey
validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
/>
The following code example demonstrates how to set the validationKey attribute and the decryptionKey attribute to manually generated random values. The validationKey attribute is set to a 256-bit long key for the HMACSHA256 hash algorithm, and the decryptionKey attribute is also set to a 256-bit long key, the longest possible for the AES encryption algorithm. These are examples only and should not be used in your application.
<machineKey
validationKey="32E35872597989D14CC1D5D9F5B1E94238D0EE32CF10AA2D2059533DF6035F4F"
decryptionKey="B179091DBB2389B996A526DE8BCD7ACFDBCAB04EF1D085481C61496F693DF5F4"
/>
