## `ASP.NET Core` 自簽憑證更新:簡單指令解決一年效期問題
在 `ASP.NET Core` 中,開發環境使用的自簽名 TLS 憑證有預設的有效期限,通常為一年。由於這些憑證的有效期限較短,因此每年需要更新一次,可以透過以下命令完成:
```bash
dotnet dev-certs https --clean
```
```bash
dotnet dev-certs https --trust
```
功能描述如下:
1. **`dotnet dev-certs https --clean`**:清除本地機器上的所有 HTTPS 開發憑證。
2. **`dotnet dev-certs https --trust`**:生成新的自簽名憑證並將其加入信任清單,使其在本地開發環境中被信任[^1] [^2]。
這些命令適用於 Windows 和 macOS 平台,並且是 .NET SDK 提供的標準工具,用於管理開發環境中的 HTTPS 憑證。[^1]。
[^1]: **dotnet dev-certs** https://learn.microsoft.com/zh-tw/dotnet/core/tools/dotnet-dev-certs
[^2]: **認識 `ASP.NET Core 7.0` 的啟動設定檔 (Launch Profile)** https://blog.miniasp.com/post/2023/03/03/Understanding-ASP-NET-Core-7-Launch-Profile