asp.net-core - ASP.NET Core 应用程序设置生产 SSL 证书

标签 asp.net-core ssl-certificate

我可以在我的开发盒上运行良好,但不能在产品中运行。

我的服务器上为我的域安装了 SSL 证书。

如何告诉我的 ASP.NET Core 应用程序使用哪个证书?我想我需要添加一些东西让它知道。

我问是因为目前我得到:

Unable to start Kestrel. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.



试图让它在 IIS 上运行,但没有任何运气,所以使用 Kestrel 进行测试只需在我的工作机器和服务器上单击它。

最佳答案

How do I tell my ASP.NET Core application which certificate to use? I assume I need to add something to let it know.



据我所知,我们可以使用 kestrel 或 IIS 来托管应用程序。

如果您想为将由 kestrel 托管的 Web 应用程序绑定(bind)证书,我建议您可以尝试通过调用以下方法来配置证书:
UseHttps(X509Certificate2 serverCertificate)

更多细节,您可以引用以下代码(程序 CreateHostBuilder 方法):
                webBuilder.UseKestrel(serverOptions =>
                {
                    serverOptions.Listen(IPAddress.Loopback, 5001,
                        listenOptions =>
                        {
                            listenOptions.UseHttps("testCert.pfx",
                                "testPassword");
                        });

                });

如果要为IIS托管的Web应用程序绑定(bind)证书,无需修改program.cs代码,直接使用IIS管理控制台设置SSL即可。

更多细节,你可以引用这个article .

关于asp.net-core - ASP.NET Core 应用程序设置生产 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62351899/

相关文章:

c# - ASP NET Core TypeFilter 属性未使用过滤器属性提供的值进行设置

c# - Microsoft.AspNet.WebApi.Client 在 github 上在哪里?

ssl - HTTPS 证书问题

android - 如何信任我的应用程序中的所有自签名证书

Apache X509 证书授权模式设置 HTTP header

c# - 如何找到所有 Controller 和 Action

c# - 更新 Entity Framework Core 中的多对多关系

ssl - 在证书名称中使用 IP 地址的异常(exception)情况

tomcat - SSL 认证问题 - Tomcat 的 Spring 和本地自签名证书

asp.net-core - ASP.NET Core 3.0 HttpContext.Current.Server.MapPath