新手在这里在ASP.NET核心应用程序中是否有内置的方法来配置HTTPS和证书?这是我尝试的。首先,我在settings.json中设置url和证书详细信息
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://localhost:5001"
}
},
"Certificates": {
"Default": {
"Subject": "<subject; required>",
"Store": "<certificate store; required>",
"Location": "<location; defaults to CurrentUser>",
"AllowInvalid": "<true or false; defaults to false>"
}
}
}
}
字符串
然后使用配置管理器加载配置
builder.Configuration
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("settings.json", false, true)
.AddEnvironmentVariables();
型
当我尝试使用postman触发API时,我得到“错误:在建立安全TLS连接之前,客户端网络套接字已断开连接”。控制器在settings.json文件中没有Certificates.Defaults部分时工作正常。
我错过了什么?
1条答案
按热度按时间q3qa4bjr1#
这是
appsettings.Production.json
的一部分,它工作得很好(Net 6/7):字符串
证书文件路径是相对于工作文件夹的。