Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core ASP.NET核心数据保护&x2B;Redis+;每台机器有多把钥匙_Asp.net Core_Redis_Antiforgerytoken_Data Protection - Fatal编程技术网

Asp.net core ASP.NET核心数据保护&x2B;Redis+;每台机器有多把钥匙

Asp.net core ASP.NET核心数据保护&x2B;Redis+;每台机器有多把钥匙,asp.net-core,redis,antiforgerytoken,data-protection,Asp.net Core,Redis,Antiforgerytoken,Data Protection,我正在配置将部署到服务器场中的.NETCore项目。我遵循了添加DataProction的所有建议,因此我的代码如下: services.AddMvc( options => { options.Filters.Add(typeof(AuditAttribute)); options.Filters.Add(new AutoValidateAntiforg

我正在配置将部署到服务器场中的.NETCore项目。我遵循了添加DataProction的所有建议,因此我的代码如下:

services.AddMvc(
            options =>
                {
                    options.Filters.Add(typeof(AuditAttribute));
                    options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
                    options.AddStringTrimmingProvider();
                }); 
var redis = StackExchange.Redis.ConnectionMultiplexer.Connect(Configuration.GetValue<string>("MySuperApp:RedisConnectionString"));
            services.AddDataProtection()
                .SetApplicationName("MySuperApp")
                .ProtectKeysWithDpapi(true)
                .PersistKeysToRedis(redis, "DataProtection-Keys");

有人能帮我吗?是否缺少服务器上的某些配置?

此处,如果删除选项:.ProtectKeysWithDpapi(true)将正常工作,所有服务器都使用相同的密钥

Exception Type: System.Security.Cryptography.CryptographicException
Exception Message: Error occurred during a cryptographic operation.
Stack Trace: at Microsoft.AspNetCore.DataProtection.Cng.DpapiSecretSerializerHelper.UnprotectWithDpapiCore(Byte* pbProtectedData, UInt32 cbProtectedData, Byte* pbOptionalEntropy, UInt32 cbOptionalEntropy)
at Microsoft.AspNetCore.DataProtection.Cng.DpapiSecretSerializerHelper.UnprotectWithDpapi(Byte[] protectedSecret)
at Microsoft.AspNetCore.DataProtection.XmlEncryption.DpapiXmlDecryptor.Decrypt(XElement encryptedElement)
at Microsoft.AspNetCore.DataProtection.XmlEncryption.XmlEncryptionExtensions.DecryptElement(XElement element, IActivator activator)
at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.IInternalXmlKeyManager.DeserializeDescriptorFromKeyElement(XElement keyElement)
Additional Info: An exception occurred while processing the key element ''.