【问题标题】:Using https with Identity Server 4将 https 与 Identity Server 4 一起使用
【发布时间】:2017-12-07 08:24:24
【问题描述】:

我已经遵循了这里的所有 IS4 教程,尽管没有一个教程强调如何在 prod 中使用 https 协议。我可能错过了一些东西,但是当我使用 https(使用我在 IIS 服务器上安装的证书)在 IIS 中部署我的 IS4 服务器时,我不能再调用tokenClient.RequestClientCredentialsAsync。如图所示,它只返回 Error=UnauthorisedErrorType=Http

我的 IS4 就是这样设置的

services.AddIdentityServer()
//.AddSigningCredential(cert)
.AddTemporarySigningCredential()...;

我也尝试过使用相同的 SSL 证书,但没有任何进展。

编辑(答案): 啊!我在部署的 IIS 站点上启用了导致该错误的基本身份验证,禁用它后,它按预期工作

【问题讨论】:

  • 您是否可以浏览 https:///.well-known/openid-configuration.if 任何错误
  • @RohithRajan 是的,我可以浏览到那个,没问题
  • 你有运气吗?
  • 这只是启用基本身份验证的问题,不久前我在答案中添加了一个编辑。不过感谢您的建议

标签: iis asp.net-core identityserver4


【解决方案1】:

AFAIK 有两种添加 https 的方法。在您的启动项目中,您可以在ConfigureServices 方法中添加以下代码

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddMvc();

    if (!_env.IsDevelopment())
        services.Configure<Microsoft.AspNetCore.Mvc.MvcOptions>(o =>
            o.Filters.Add(new Microsoft.AspNetCore.Mvc.RequireHttpsAttribute()));
    //...
}

或者将RequireHttps 属性添加到您的控制器中,并启用 SSL

【讨论】:

    猜你喜欢
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 2020-05-13
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    相关资源
    最近更新 更多