'Converting machineKey (from web.config) to key.xml for .NET Core data protection

I'm trying to run two ASP.NET projects (one .NET Framework 4.8 & the other .NET Core 6) in parallel while I convert code slowly into the .NET Core 6 project. I need these two webapps to work with cookie validation/MachineKey.Protect at the same time for a session. I'm working on converting the .NET Framework project to use the Microsoft.AspNetCore.DataProtection.SystemWeb (Nuget) so that I can get a common key/cert location for both applications. I followed the instructions from MS docs but when I run my application it just generates a new key that isn't based on the existing values in the machineKey config section of the web.config?

Is there a way to to take an existing MachineKey section from a ASP.NET 4.8 web.config file and convert it to the key XML format (or cert)?

So take something like:

<machineKey 
decryption="AES" 
decryptionKey="asdfasdflkjas;dlkfjasdf" 
validation="SHA1" 
validationKey="blahblah"  />

and convert it to:

enter image description here

Any help is appreciated.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source