Ask about: Add Redis as a data protection key repository

225 Views Asked by At

I have the problem is that when I use the protect key stored on redis to protect data and I delete protect key on redis to test whether it still works for unprotect. The result is that it still work. So, I can not understand this.

I have already added Redis as a data protection key repository:

services.AddDataProtection().PersistKeysToStackExchangeRedis

when I start project, protect key stored on redis. And I use this protect key to protect data in HomeController

_dataProtector = dataProtectionProvider.CreateProtector("MySessionData");

var protectedText = _dataProtector.Protect(Encoding.UTF8.GetBytes(plainText));

var plainData = _dataProtector.Unprotect(protectedText);

The question here is that after I run code to protect data then I delete protect key on redis cache and continue run code at unprotect, I see that although not still exists protect key on redis cache, it works on unprotect without any error. Could you please explain for me. Thanks a lot.`

0

There are 0 best solutions below