【发布时间】:2017-02-26 17:16:40
【问题描述】:
我正在尝试学习 IdentityServer4,因此我从 https://identityserver4.readthedocs.io/en/dev/quickstarts/0_overview.html 此处的文档开始,并以 https://identityserver4.readthedocs.io/en/dev/quickstarts/1_client_credentials.html 结束。
只要我使用 http,一切都很好,但是一旦我切换到使用 https,客户端测试器中的第一行代码
var disco = await DiscoveryClient.GetAsync("https://localhost:44384");
挂起并最终获得任务取消异常。
如果我只是将所有内容切换回 http,它就会重新开始工作。
在实际的IdentityServer方案中,我更改了launchSettings.json中的applicationUrl和launchUrl:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44384/",
"sslPort": 44384
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Mvcg.IdentityServer": {
"commandName": "Project",
"launchUrl": "https://localhost:44384",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
和 Program.cs 中的 .UseUrls
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls("https://localhost:44384")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
在客户端解决方案中,如上所述,我将调用发现端点的代码更改为使用 https 而不是 http
var disco = await DiscoveryClient.GetAsync("https://localhost:44384");
需要明确的是,只需在 http 和 https 之间更改所有注明的项目,对 http 有效,但对 https 无效。我的两次测试之间没有其他变化。
是我遗漏了什么导致 https 无法工作吗?
【问题讨论】:
-
当您在浏览器中访问站点和发现文档时会发生什么?任何给您提示的 asp.net 日志(提高日志级别以进行跟踪)
-
在 Visual Studio 中启动解决方案后,我在浏览器中转到 localhost:44384/.well-known/openid-configuration,它只是说“无法访问此站点。localhost 响应时间太长。”开发人员工具显示 ERR_TIMED_OUT。有趣的是,我从github.com/IdentityServer/IdentityServer4.Samples 下载了样本并尝试了相同的测试。我从http切换到https,同样的事情发生了。我会查看日志,看看是否有任何帮助。
标签: https asp.net-core identityserver4