-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Android Chrome - Cryptographic Exception #6480
Comments
This error is definitely coming from our stack. This is the piece of code that tries to decrypt temporary data stored in a cookie. This should not be crashing like this even if the data can't be decrypted. But we will probably need more information to really understand the cause @blowdart - ideas about when/how this could occur? Could this be due to ephemeral keys on linux? @troncomputers - what's the server platform? |
I'm moving this issue to MVC which is a more appropriate place for it. |
Also is the user authenticated when this happens? |
@rynowak |
The relevant part of the stack is this:
@blowdart - does the encrypted data get stamped with a key identifier? That's what this looks like to me. To repeat, we should not be throwing an exception when something like this happens - temp data is optional/transient and all kinds of things can go wrong. However, I want to understand if something underlying is broken as well. |
I can make an account for you on my project website to test it. There are still fake data so you can do whatever you want to fix this. |
@rynowak Yes everything that goes through data protection keys a KID. @troncomputers Can you turn on debug logging and watch what happens at app startup? There may be a data protection log in there I'd like to see. Did you run the deployment script for data protection and IIS? Or does the app pool load a profile? |
@blowdart Like I said, I am new to ASP .NET, I need some guidance if you want satisfying answer. Sorry about that but I'm trying to learn on that project.
My Program.cs
And Login.cshtml.cs (Login model class)
|
Ok, if this is in a production environment, or under IIS rather than IIS express there's a step you need to go through first; Near the bottom of the IIS docs is a section on configuring data protection, which gives you the following options; To configure Data Protection under IIS you must use one of the following approaches:
I'd try option 1 or two first. You need 3 if you're going to load balance over multiple machines. |
@blowdart First of all after I did first 2 points website on desktop is just 1000% faster - faster loading, faster searching (getting data from database) etc. |
Aha. it works? Great. So what happens in data protection is we generate our own encryption keys, and rotate them. But if you don't configure where they're stored it has to start again from scratch, as they are only retained in memory for as long as your app runs. Generating keys takes a little while, so you're incurring that cost every time you restart your app. So it would explain the initial load at least. But nothing else :) |
You said that you should not throw exception when decripting cookies. Is it still a bug or just my no experience? |
It should work fine now, well, for identity and csrf cookies. If it's still happening then something else is going on. |
Thanx for help, you saved my life 👍 |
@Eilon - thoughts on making this not throw for 2.0.0? |
It needs to error somehow I'm afraid. |
Let's discuss this briefly tomorrow, I want to understand your concerns |
This change logs when we encounter and exception reading temp data from a cookie and swallows the exception. Additionally, we clear the cookie so that this won't happen on subsequent requests. This will handle cases where data protection is misconfigured, or a request just has general garbage in the cookies.
This change logs when we encounter and exception reading temp data from a cookie and swallows the exception. Additionally, we clear the cookie so that this won't happen on subsequent requests. This will handle cases where data protection is misconfigured, or a request just has general garbage in the cookies.
From @troncomputers on July 2, 2017 9:11
Hi!
Sometimes we are getting Cryptographic Exception on Android Chrome. Never happend on desktop.
I'm new to ASP, specialy Core.
Project is made with ASP .NET Core WebPages (Razor with seperate model class) with EntityFramework.
Microsoft.AspNetCore.All
2.0.0-preview1-final
ERROR:
I posted this error on different repo and someone explain me that this is a server side error and has nothing to do with Android. I'm getting this exception only on mobile.
Android puts allmost every app to 'background', maybe is cache problem or ASP session with old "session keys".
Please help!
Copied from original issue: dotnet/aspnetcore#2083
The text was updated successfully, but these errors were encountered: