-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
There is a bug in the usage of the Microsoft.AspNetCore.DataProtection.SystemWeb nuget package.
I have a basic ASP.NET MVC .NET 4.8 project created using the examples in the article with the DataProtectionDemo.cs and using the Microsoft.AspNetCore.DataProtection.SystemWeb nuget package. I did everything exactly how the article described. Setup as follows:
-I created a basic .NET Core Console application injecting the IDataProtectionProvider and setting up the AddDataProjection() exactly how it was done in the first example (but in core).
If I protect a value (any value) on the ASP.NET site and try and unprotect that value on the console application I get the "The payload was invalid.". Either there missing information in that product article critical to getting this working, or there is a bug in the process. I've double-checked everything the article mentions.
keys are generated correctly in the same file location for both applications
application name is exactly the same in both applications (my-app)
I have generated a github repo reproducing the error here https://github.com/palmej2/DNETFW-2-DNETCORE
NOTE: This is issue originated from dotnet/AspNetCore.Docs#24847 and was directed to make bug
Expected Behavior
Anything encrypted in .NET FW 4.8 should be able to be decrypted and read in .NET as long as the same security keys are used in both applications.
Steps To Reproduce
Get https://github.com/palmej2/DNETFW-2-DNETCORE
Instructions to recreate issues found:
- The default folder is for the keys is C:\test\myapp-keys. If you want to change it update the code in consoleapp1/program.cs & WebApplication1/DataProtectionDemo.cs.
- Run the WebApplication project and copy the decrypted value that it produces.
- Run the ConsoleApp1 project and paste that decrypted value into it.
Currently #3 is failing, and it shouldn't fail. It should decrypt the value correctly, which currently should be "TEST VALUE".
Exceptions (if any)
System.Security.Cryptography.CryptographicException: 'The payload was invalid. For more information go to http://aka.ms/dataprotectionwarning'
.NET Version
4.8/6.0
Anything else?
No response