macOS Monterey 運行 ASP.NET Core 提示錯誤 The ASP.NET Core developer certificate is in an invalid state.

問題:安裝新版本 .NET 6.0 SDK 後,運行 ASP.NET Core 項目出現如下錯誤:

fail: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[4]
The ASP.NET Core developer certificate is in an invalid state. To fix this issue, run the following commands 'dotnet dev-certs https --clean' and 'dotnet dev-certs https' to remove all existing ASP.NET Core development certificates and create a new untrusted developer certificate. On macOS or Windows, use 'dotnet dev-certs https --trust' to trust the new certificate.

由於默認的是 https 鏈接,之前的開發證書對於新版本的 SDK 不起作用,需要重新按照提示依次運行以下命令:

dotnet dev-certs https --clean
dotnet dev-certs https

// 根據提示,macOS 和 Windows 上還需要運行下面的命令
dotnet dev-certs https --trust

按照提示,運行完以上命令,再次運行 dotnet watch run 後,在應用程序啓動的過程中,還是會有一次輸入密碼的提示,但是輸入密碼後,運行不正常。經過多次嘗試,發現是輸入密碼太慢,輸入密碼後,應用程序已經出現錯誤。所以輸入密碼要快,趕在應用程序啓動起來之前輸入完成。記錄以備查詢,希望也能幫助到其他人。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章