【发布时间】:2020-10-12 09:13:34
【问题描述】:
有一个 .net core 3.0 web 应用程序,里面有 IdentityServe4。应用程序托管在 Azure Web 场上。 在日志中,我发现消息有几个例外:
读取受保护消息的异常 - 提供的有效负载无法解密,因为它不受此保护提供程序的保护。
请求路径:/connect/endsession/callback
堆栈跟踪:
System.Security.Cryptography.CryptographicException:
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore
(Microsoft.AspNetCore.DataProtection, Version=3.1.8.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect
(Microsoft.AspNetCore.DataProtection, Version=3.1.8.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect
(Microsoft.AspNetCore.DataProtection, Version=3.1.8.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60)
at IdentityServer4.Stores.ProtectedDataMessageStore`1.ReadAsync (IdentityServer4, Version=3.1.3.0,
Culture=neutral, PublicKeyToken=f294d0afe402bb2b)
数据保护设置:
services.AddDataProtection()
.PersistKeysToAzureBlobStorage(container, keyStorage.Path)
.ProtectKeysWithAzureKeyVault(client, keyEncryption.KeyIdentifier)
最近,我们添加了services.AddOidcStateDataFormatterCache(schemes); 和SQL Distributed 缓存实现。
有人知道为什么会发生这个异常以及如何解决它吗?
【问题讨论】:
-
错误表明客户端和服务器(包括证书)没有使用相同的加密算法(和设置),因此服务器无法验证密钥。如果您删除了最近的增强功能,代码是否有效?五年前,由于安全问题,业界淘汰了 TLS 1.0/1.1,并要求使用 TLS 1.2/1.3。 6 月,微软推出了一项安全更新,该更新禁用了服务器上的 TLS 1.0/1.1。我之前没有看到您的异常,所以我不确定您的更改是否导致异常或异常是由于客户端使用 TLS 1.0/1.1 和服务器拒绝连接。
-
感谢您的回复,很好的假设。问题是代码正在运行,我无法重现它。但我不时会看到 Application Insight 日志。
-
知道错误发生多长时间。请求开始时是否应该记录日志文件?请参阅:social.msdn.microsoft.com/Forums/azure/en-US/…
标签: c# .net-core identityserver4 asp.net-core-3.1