簡體   English   中英

Visual Studio:“信任證書失敗”

[英]Visual Studio: "Failed trusting the certificate"

On Windows 10/11, With Visual Studio 2017-2022, when serving a web API via HTTPS with Kestrel or IIS, Visual Studio prompts me to trust the self-signed certificate that ASP.NET Core has generated.

如果我單擊“是”,我會收到以下錯誤:

將證書添加到受信任的根證書存儲失敗並出現以下錯誤:信任證書失敗。 (運行 Kestrel)或訪問被拒絕。 (運行 IIS)

通過 Chrome 導航到 swagger UI 頁面驗證證書確實無效並且連接不安全。

運行dotnet dev-certs https --trust結果

信任 HTTPS 開發者證書時出錯。

從 certmgr 我可以看到 ASP.NET 核心 HTTPS 開發證書已安裝在當前用戶/個人商店中。 我還看到了Trusted Root Certification Authorities -store 和里面的證書。

如果我嘗試將證書拖放到 Trusted Root Certification Authorities -store,我會收到以下錯誤消息:

無法將證書粘貼到受信任的根證書頒發機構 - 存儲中。 訪問被拒絕。

如果我嘗試將證書導入所述商店,我會收到以下錯誤消息:

導入失敗,因為存儲是只讀的、存儲已滿或存儲未正確打開。

如果我嘗試從導出的文件安裝證書,通過'Install certificate' -> 'Current User' -> 'Place all certificates in the following store' -> Browse ,我看不到Trusted Root Certification Authorities -store一點也不。

如果我 select 'Certificates - Current User' -header, go to View -> Options, and enable 'Physical certificate stores' ,我可以將證書拖放到物理存儲Trusted Root Certification Authorities/Local Computer/Certificates

該證書現在在受信任的根證書頒發機構存儲中可見,但 Visual Studio 仍然拋出相同的錯誤,瀏覽器認為該證書不受信任,並且dotnet dev-certs https --check --trust輸出:

未找到有效證書。

如果我將原始證書留在Personal中,則在沒有私鑰的情況下將其導出並將導出導入實體店Trusted Root Certification Authorities/Local Computer/Certificatesdotnet dev-certs https --check --trust打印:

找到受信任的證書:...

...但瀏覽器仍然認為證書無效,並且 Visual Studio 會拋出錯誤。

dotnet run的結果相同,在 Visual Studio 中沒有信任錯誤。 dotnet CLI 似乎不檢查或嘗試信任證書。

相同但不同:如果我從 Chrome 保存證書並嘗試通過Chrome -> Settings -> Privacy and security -> Manage certificates -> Trusted Root Certification Authorities -> Import將其添加到Trusted Root Certification Authorities ,我也會收到:

導入失敗,因為存儲是只讀的、存儲已滿或存儲未正確打開。

我已經用完了可以嘗試的東西,而且我可能缺少一些基本的東西。 我應該怎么辦?

事實證明,雖然我確實刪除了用戶和機器存儲中的所有 localhost 證書,並重新安裝了 IIS,但在此過程中安裝了某種錯誤的 localhost 證書,我需要再次刪除它們,然后將瀏覽器中可見的安裝到本地計算機證書受信任的根證書存儲。

希望這對將來的某人有所幫助。 始終檢查您的序列號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM