我有一个非常基本的自托管.NET核心2.1应用程序,配置如下:
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();
host.Run();
}
}和非常典型的简单控制器如下:
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}当我测试这个应用程序并导航到我的HTTPS本地端点端口(在我的例子中是44325)时,这个应用程序工作得很好:
https://localhost:44325/api/values

目前为止一切都很好。现在,我想知道这个HTTPS连接的证书来自何处,因为我没有使用IIS Express,而且证书实际上不属于IIS Express:

当我搜索证书存储区的拇指指纹时,我找不到上面的证书。如何生成此证书?我在哪里可以找到它?为什么此证书在Edge和chrome中工作,但在Firefox中却不受信任?它是在飞行中产生的吗?
我的启动设置如下:
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55894",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Experimental1": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:44325;http://localhost:55894",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}我使用的是Experimental1配置文件,而不是IIS,在运行应用程序时,我看到了我的小控制台。
发布于 2018-07-10 14:15:40
如何生成此证书?
.NET Core第一次运行dotnet new时生成证书
请参阅https://blogs.msdn.microsoft.com/webdev/2018/02/27/asp-net-core-2-1-https-improvements/
我在哪里可以找到它?
SDK将ASP.NET核心HTTPS开发证书安装到本地用户证书存储中。
localhost

为什么此证书在Edge和chrome中工作,但在Firefox中却不受信任?
确实如此。即使在运行dotnet dev-certs https --trust之后,Firefox也不信任证书,并抱怨说:“证书是不可信的,因为它是自签名的。”
可能就是那个Firefox不再信任自签名证书。。我的解决办法是添加一个安全异常。

https://stackoverflow.com/questions/51267154
复制相似问题