Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding machineKey to machine.config

Tags:

I would like to add the machineKey to my machine.config since I am working with programmatic encryption of web.config connection strings in a web farm scenario.

My question is, where do I place the machineKey in the machine.config file? There isn't one already there that I can replace, I suspect it's being autogenerated, so where should it be placed?

like image 566
Rami Alhamad Avatar asked Apr 26 '12 16:04

Rami Alhamad


People also ask

Where do I put MachineKey in web config?

If you have access to the IIS management console for the server where Orchard is installed, it is the easiest way to set-up a machine key. Uncheck "Automatically generate at runtime" for both the validation key and the decryption key. Click "Generate Keys" under "Actions" on the right side of the panel. Click "Apply".

What is the use of MachineKey in IIS?

The Machine Key is used to hash and/or encrypt cookies for the Alpha Anywhere Application Server for IIS. If multiple servers running IIS have different Machine Keys, the cookies created on one machine won't be usable on the other.

What is use of MachineKey in web config?

The MachineKey section can be configured at the machine (Machine. config) or application (Web. config) level and controls the keys and algorithms that are used for Windows Forms authentication, view-state validation, and session-state application isolation.

What is MachineKey validationKey?

"validationKey specifies a manually assigned validation key. This value must be manually set to ensure consistent configuration across a network of Web servers (a Web farm). The key must be a minimum of 40 characters (20 bytes) and a maximum of 128 characters (64 bytes) long.


2 Answers

Just place it under <system.web>

If you need a key generated, use the process as shown in this SO post

like image 136
peroija Avatar answered Oct 15 '22 18:10

peroija


Inside <system.web>:

<system.web>
    <machineKey 
        validationKey="....." 
        decryptionKey="....." 
    />

which is at the bottom of the file in mine at least. I don't think the order of elements in system.web matters, as long as it's the top level directly beneath the system.web element.

like image 44
Rup Avatar answered Oct 15 '22 19:10

Rup