ASP.NET Core Azure AD OpenID - 生产服务器上的 token 签名验证失败

标签 asp.net azure asp.net-core-mvc jwt openid-connect

我有一个 ASP.NET Core 1.1 项目,使用 Azure AD OpenID 进行身份验证。身份验证在我的开发盒(Windows 10)上运行良好,无论是在 IIS Express 还是完整的 IIS 上。但是,当我将项目部署到我的服务器(Server 2008R2)时,登录 Microsoft 重定向站点后,服务器抛出此错误:

Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException:IDX10503:签名验证失败。尝试过的 key : 'Microsoft.IdentityModel.Tokens.X509SecurityKey ,KeyId:VWVIc1WD1Tksbb301sasM5kOq5Q Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException:发生内部错误 在Internal.Cryptography.Helpers.OpenStorageProvider(CngProvider提供商) 在 System.Security.Cryptography.CngKey.Import(Byte[] keyBlob,字符串 curveName,CngKeyBlobFormat 格式,CngProvider 提供程序) 在 System.Security.Cryptography.CngKey.Import(Byte[] keyBlob,CngKeyBlobFormat 格式) 在Internal.Cryptography.Pal.X509Pal.DecodePublicKey(Oid oid,字节[]编码KeyValue,字节[]编码参数,ICertificatePal证书Pal) 在Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPublicKey[T](X509Certificate2证书,Predicate`1 matchesConstraints) 在 Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PublicKey() 在 Microsoft.IdentityModel.Tokens.CryptoProviderFactory.IsSupportedAlgorithm(字符串算法,SecurityKey key ) 在 System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(Byte[]encodedBytes,Byte[] 签名,SecurityKey key ,字符串算法,TokenValidationParametersvalidationParameters) 在System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(字符串 token ,TokenValidationParameters验证参数)

当我将从 Azure 收到的 token 插入 JWT.io 时,它会成功验证签名。

回顾一下:

  • 开发盒(iis express 和 iis) token 签名验证成功
  • JWT.io 调试站点、 token 和签名验证成功
  • 部署在服务器(iis 7.5)签名验证失败

这与我服务器上的 https 证书有什么关系吗?在我的开发盒上,我使用的是使用 powershell 创建的自签名证书。在服务器上,我们有一个由 go-daddy 颁发的证书。

感谢您的帮助。

最佳答案

关于ASP.NET Core Azure AD OpenID - 生产服务器上的 token 签名验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45596580/

相关文章:

c# - like 使用参数的 npgsql 语句

javascript - 从 Javascript 调用 VB.NET WebMethod 函数

azure - 如何通过 Azure Functions 在 VSTS 包管理中使用 NuGet 包?

c# - 我可以在 .NET Standard 类库中使用动态吗?

asp.net、url 重写模块和 web.config

c# - 强制回发 Asp.Net

c# - Azure 项目的 schemaVersion 错误

java - 如何使用 Maven 插件部署具有多个名称的 Azure Function?

Asp.net 5 MVC 6, 为 facebook 电子邮件添加权限

asp.net-core - 依赖项Microsoft.Composition 1.0.27不支持框架.NETCoreApp,Version = v1.1