【问题标题】:Security token validation between Identity Server 4 and 3Identity Server 4 和 3 之间的安全令牌验证
【发布时间】:2018-02-01 20:28:26
【问题描述】:

我正在尝试使用 .Net Core 2.0 上的 IdS4 服务器和 .Net45 上的 IdS3 webforms 客户端。

当我通过客户端登录时,我在客户端浏览器上收到此异常。

[SecurityTokenSignatureKeyNotFoundException: IDX10500: Signature validation failed. Unable to resolve SecurityKeyIdentifier: 'SecurityKeyIdentifier
(
    IsReadOnly = False,
    Count = 2,
    Clause[0] = X509ThumbprintKeyIdentifierClause(Hash = 0x6B7ACC520305BFDB4F7252DAEB2177CC091FAAE1),
    Clause[1] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause
)
', 
token: '{"alg":"RS256","kid":"6B7ACC520305BFDB4F7252DAEB2177CC091FAAE1","typ":"JWT",
"x5t":"a3rMUgMFv9tPclLa6yF3zAkfquE"}.{"nbf":1517303703,"exp":1517304003,
"iss":"http://localhost:5000","aud":"webforms","nonce":"636529004845229500.Mjg4YmMxMGEtZjk2MC00YWY5LWJiNTQtYmU0Njg0MDIwYTFhNzczN2Q1ZGMtN2YxYy00NGJmLWJhNzItNTM1ZDc0OTMyNzBj",
"iat":1517303703,"c_hash":"6Sty4gdTWGo4nEo0V_VSVQ","sid":"17936a127b0267d2588646052c4447c6",
"sub":"6498d093-8dc3-4d69-988e-3914d564f4d0","auth_time":1517303700,
"idp":"local","amr":["pwd"]}'.]

我首先在没有 Clause[0] 的情况下得到了这个异常,并认为这是因为我使用的两个样本中嵌入了不同的证书。

我尝试解决此问题涉及按照 this 指南创建新证书。

在 IdS4 启动中我有

services.AddIdentityServer()
            .AddSigningCredential(GetSigningCredential())

private X509Certificate2 GetSigningCredential()
    {
        var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
        store.Open(OpenFlags.ReadOnly);
        var certs = store.Certificates.Find(X509FindType.FindBySerialNumber, "3506fe4f69dc22b340e9c2af500d4659", false);
        store.Close();
        return certs[0];
    }

将客户端密码设置为 X509 指纹。

这似乎有效。在 IdS3 客户端上,我找不到验证安全令牌的方法,我认为这将通过验证证书来完成?

如果有人可以帮助我更好地理解我的问题,那就太好了,我找不到任何与我的案例相关的有用文档或示例,所以几乎任何东西都会有所帮助。

提前致谢。

【问题讨论】:

  • 您在身份服务器项目的Startup.cs 中是否有services.AddTemporarySigningCredential()services.AddDeveloperSigningCredential()?因为这可能是您的密钥无效的原因。
  • 这是我改变的第一件事。我猜想从 IdS3 到 IdS4 的开发签名凭据之间可能存在差异。我确实认为这可能是因为我不知道在哪里告诉 IdS3 客户端如何验证证书

标签: webforms identityserver4 identityserver3


【解决方案1】:

原来我试图在错误的地方进行验证。我所要做的就是指向客户端 Startup.cs 中的证书。

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
    Configuration = new OpenIdConnectConfiguration()
    {
        // Other Stuff...
        SigningTokens = { new X509SecurityToken(GetX509Certificate2()) },
        // More Stuff...

GetX509Certificate2() 在哪里:

private X509Certificate2 GetX509Certificate2()
{
    var store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine);
    store.Open(OpenFlags.ReadOnly);
    return cert = store.Certificates.Find(X509FindType.FindByThumbprint, "**thumbprint**", false)[0];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-08
    • 2018-11-29
    • 2020-12-07
    • 2018-09-23
    • 1970-01-01
    • 2018-09-14
    • 1970-01-01
    • 2020-02-06
    相关资源
    最近更新 更多