Asp.net core ASP.NET核心数据保护&x2B;Redis+;每台机器有多把钥匙
我正在配置将部署到服务器场中的.NETCore项目。我遵循了添加DataProction的所有建议,因此我的代码如下: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
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 ''.