我在 appsetting.json 中有这个 Kestrel 设置
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:7514"
},
"Https": {
"Url": "https://0.0.0.0:7513"
"Certificate": {
"Path": "myCert.pfx",
"Password": "somePassword"
}
}
}
},
并将其放在 appsetting.development.json 中
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:7514"
},
"Https": {
"Url": "https://0.0.0.0:7515"
}
}
}
在开发模式下,它使用开发应用程序设置中的正确端口,但仍然需要证书,我如何覆盖该设置,以便不需要证书
这是设置
var webApplicationOptions = new WebApplicationOptions() { ContentRootPath = AppContext.BaseDirectory, Args = args, ApplicationName = System.Diagnostics.Process.GetCurrentProcess().ProcessName };
var builder = WebApplication.CreateBuilder(webApplicationOptions);
builder.Host.UseWindowsService();
如果要使用https,则必须需要证书,它使用证书来保护客户端和服务器之间的连接。如果不使用它,我们就无法使用客户端和服务器之间的 tls 连接。
如果您不想为https设置证书,可以删除https部分,仅使用http进行测试。