我可以在我的开发盒上运行良好,但不能在产品中运行。
我的服务器上为我的域安装了 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/