失败:Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery

问题描述 投票:0回答:2

我在yml文件中有4个docker容器。

  1. Db容器
  2. 身份服务器容器(带有身份服务器的asp.net核心应用程序)
  3. Api服务器(asp.net核心应用程序)
  4. 客户端(Angular 9应用)

一切都在开发Windows机器上运行良好,我将其部署在Windows服务器上的一个客户端上,并将所有应用程序托管在IIS上,并在IIS上拥有3个不同的站点和一个单独的数据库。

现在,我想要将其部署在linux docker容器上,总体配置很好,尽管需要改进(我可以做到),但是我被以下错误所困,并且在身份服务器容器上的docker日志显示如下错误

失败:Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery [7] 反序列化令牌时引发异常。 Microsoft.AspNetCore.Antiforgery.AntiforgeryValidationException: 反伪造令牌无法解密。 -> System.Security.Cryptography.CryptographicException:密钥 在钥匙圈中找不到{d7972341-6e64-467d-af09-124f5ba3e3a8}。 在 Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte [] protectedData,布尔allowOperationsOnRevokedKeys,UnprotectStatus& 状态) Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte [] protectedData,布尔值ignoreRevocationErrors,布尔值& requireMigration,Boolean&wasRevoked) Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte [] protectedData) Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)-内部异常堆栈跟踪的结尾-在 Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgeryTokenSerializer.Deserialize(String serializedToken)在 Microsoft.AspNetCore.Antiforgery.Internal.DefaultAntiforgery.GetCookieTokenDoesNotThrow(HttpContext httpContext)

[请记住,我正在使用pfx文件作为Identity Server容器上的证书。

我只是不知道此密钥问题将在哪里出现,而在钥匙圈中找不到该密钥在哪里?

任何帮助或讨论将不胜感激。

成功后,我想在Digital Ocean上部署它

c# identityserver4 antiforgerytoken linux-containers
2个回答
0
投票

[经过重新研究和不同的解决方案之后,得到一种解决方案似乎有些奏效。这篇文章的解决方案https://github.com/dotnet/aspnetcore/issues/3540到目前为止,Chiodino的效果很好。

我要做的是重新创建具有所有不同端口绑定的所有容器,是的,它可以工作并生成可以被Identity Server解密的适当密钥。


0
投票

当显示的防伪令牌不在应用程序的持久授权中时,会出现此错误。您是在实现IPersistedGrant接口还是将这些信息保存在内存中?发布或重新启动服务器后出现此错误?

一个常见的原因是将该信息存储在内存中并重新启动服务器。

另一个原因是删除dbo。“ PersistedGrants”数据库上的信息。

如果已实现IPersistedGrants接口,那么该数据库是否有多个实例?

希望对您有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.