首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于自签名证书的IdentityServer 4 Https

基于自签名证书的IdentityServer 4 Https
EN

Stack Overflow用户
提问于 2021-02-04 21:11:36
回答 1查看 418关注 0票数 1

在本地,我有一组web应用程序,所有这些应用程序都可以通过一次登录访问。为此,我采用了Identity Server 4。

一旦应用程序发布到本地服务器上,而不能远程访问,我就通过openssl生成了一个SSL证书,并设置IIS使用它。

特别是,我的机器可以通过本地dns访问。例如,我的机器ip为192.168.15.3,别名为app.server.lan

如果我连接到该站点的主页(app.server.lan),Google Chrome会检测到该站点是安全的。但是,当我尝试访问应用程序,然后启动应用程序和身份服务器之间的连接时,我得到一个错误页面,日志中包含以下错误:

代码语言:javascript
复制
2021-02-04 14:09:04.6785|1|ERROR|Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware|An unhandled exception has occurred while executing the request. 
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden]'. 
---> System.IO.IOException: IDX20804: Unable to retrieve document from: '[PII is hidden]'. 
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. 
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. 
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

PPI是隐藏的:.well-known/openid-配置,如果我通过浏览器检查,它是可见的。

我该怎么解决呢?我可以使用没有https的IdentityServer 4吗?

你看到的黑线是app.server.lan

5000是标识服务器端口

443是主要的应用程序端口

5001到5005是其他应用程序端口

EN

回答 1

Stack Overflow用户

发布于 2021-02-08 18:54:02

下面是从商店获取certioficat的代码:

代码语言:javascript
复制
X509Certificate2 cert = null;
using (var certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine))
{
    certStore.Open(OpenFlags.ReadOnly);
    var certCollection = certStore.Certificates.Find(
        X509FindType.FindByThumbprint,
        "<THUMBPRINT>", // Change this with the thumbprint of your certifiacte
        false);

    if (certCollection.Count > 0)
    {
        cert = certCollection[0];
    }
}

代码语言:javascript
复制
if(cert == null)
{
    // If the certificate is not installed, you might be in development and want to ise the developer credebntials
    services.AddIdentityServer()
        .AddDeveloperSigningCredential();
}
else
{
    services.AddIdentityServer()
        .AddSigningCredential(cert);
}

确保运行IdentityServer应用程序的应用程序池标识有权访问私钥。如果没有,就给它权限。

在iis应用程序池高级设置中将加载用户配置文件设置为"true“。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66046362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档