✅ 撤銷 dotnet dev-certs https --trust 的方法
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/1159
如果你問:
💥「我已經執行了
dotnet dev-certs https --trust
,現在後悔了,有沒有辦法撤銷這個動作?」
答案是:✅ 有!完全可以撤回,讓系統不再信任這張開發憑證。
✅ 撤銷 dotnet dev-certs https --trust
的方法
🧼 方法 1:刪除開發憑證(最乾淨)
在命令列(cmd
或 PowerShell)執行:
dotnet dev-certs https --clean
這會:
-
❌ 刪除目前使用中的 ASP.NET Core HTTPS 憑證(包含已信任的)
-
✅ 相當於「清除
--trust
的後悔藥」 -
✅ Visual Studio 之後啟動會問你要不要重新產生憑證
🧪 方法 2(可選):手動從憑證管理工具中移除
如果你要手動操作也行:
-
打開 Windows 的「憑證管理工具」:
-
Win + R → 輸入
certmgr.msc
→ Enter
-
-
展開左邊:
受信任的根憑證授權單位(Trusted Root Certification Authorities) └─ 憑證(Certificates)
-
找到名稱類似:
localhost ASP.NET Core HTTPS development certificate
→ 右鍵 → 刪除
-
同樣檢查「個人」→「憑證」中是否也有,要一併刪除。
🔁 想恢復信任怎麼辦?
只要再跑一次即可:
dotnet dev-certs https --trust
✅ 總結
動作 | 指令 |
---|---|
撤銷信任並刪除憑證 | dotnet dev-certs https --clean |
恢復信任(可選) | dotnet dev-certs https --trust |
顯示目前的憑證路徑 | dotnet dev-certs https --check |
This article was last edited at