title: .Net Core Machine Key alternative for webfarm
body: <p>I have been using dotnet core to create an application that runs in a Kubernetes cluster on Linux hosts. As I was testing it noticed getting exceptions when validating the CSRF tokens, that makes sense since I did not edit the machine key to be the same on every instance yet. As i proceeded to set the machine key in web.config i noticed this would no longer work in .Net Core. </p>
  
  <p>As is is now using the DataProtection API, the machine key no longer worked. I tried implementing the api into my application, but when i read i would need to use a network share to exchange the keys between all instances i was stunned. Surely there must be an easier (and better) way to accomplish this without having to rely on a share to be online right?</p>
  
  <p>i tried to set the following in the Startup class in the ConfigureServices method:</p>
  
  <p><code>services.AddDataProtection().SetApplicationName("DockerTestApplication");</code></p>
  
  <p>I somehow expected the keys to be generated using the applicationname, but this did not resolve the issue.</p>
  
  <p>I found some interesting docs that all use code that will no longer compile, i guess Microsoft changed up some things:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey</a></p>
  
  <p>Does anyone know a solution to this problem that will also run on Linux and has the ability to share the tokens over the network between instances?</p>
  
  <p>Thanks in advance!</p>