Identityserver3 错误无法从以下位置获取文档:https://localhost:44300/identity/.well-known/openid-configuration

Identityserver3 error Unable to get document from: https://localhost:44300/identity/.well-known/openid-configuration

我已经创建了一个身份服务器来颁发令牌。使用 identityserver3 进行设置。 我正在使用带有密码的本地 .pfx 证书来签署令牌。

这工作正常,但不确定为什么我会收到附件中显示的以下错误。

真让我抓狂。

下面是授权服务器上startup.cs中的代码。证书文件位于 \bin\debug 文件夹

public class X509Certificate2Wrapper : IX509Certificate2Wrapper
{
    public X509Certificate2 LoadCertificate(string filename, string password)
    {
        var path = $@"{AppDomain.CurrentDomain.BaseDirectory}{filename}";

        return new X509Certificate2(path, password);
    }
}

    app.Map("/identity", idsrvApp =>
    {
        idsrvApp.UseIdentityServer(new IdentityServerOptions
        {
            SiteName = "Identity Manager",
            IssuerUri = Common.Constants.IdSrvIssuerUri,
            SigningCertificate = X509Certificate2Wrapper.LoadCertificate(CertificateFilename, CertificatePassword),
            Factory = factory,
            RequireSsl = true,
            EnableWelcomePage = false,
            AuthenticationOptions = new AuthenticationOptions
            {
                EnableSignOutPrompt = false,
                EnablePostSignOutAutoRedirect = true,
                PostSignOutAutoRedirectDelay = 3,
                CookieOptions = new IdentityServer3.Core.Configuration.CookieOptions
                {
                    ExpireTimeSpan = new TimeSpan(0, IdentityServerServices.AuthenticationTimeout(), 0),
                    SlidingExpiration = true
                },
                //
                // Note: Uncomment following line to enable WindowsAuthentication only - logout related settings will also require removal!
                //
                //EnableLocalLogin = false,
                IdentityProviders = ConfigureIdentityProviders
            },
            Endpoints = new EndpointOptions
            {
                EnableAccessTokenValidationEndpoint = true,
                EnableAuthorizeEndpoint = true,
                EnableCheckSessionEndpoint = false,
                EnableClientPermissionsEndpoint = false,
                EnableCspReportEndpoint = false,
                EnableDiscoveryEndpoint = true,
                EnableEndSessionEndpoint = true,
                EnableIdentityTokenValidationEndpoint = true,
                EnableIntrospectionEndpoint = false,
                EnableTokenEndpoint = true,
                EnableTokenRevocationEndpoint = false,
                EnableUserInfoEndpoint = true
            }
        });
    });

不确定这是不是完美答案。但是我做了以下并且对我来说一切正常。

i) 按照 https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/Certificates

中提到的有关证书的步骤进行操作

ii) 为了解决这个问题,我将 "localhost" IIS Express 证书从个人 CertStore 移到了受信任的根证书颁发机构,问题就消失了。