共用方式為


macOS 不支援 OpenSSL 密碼編譯基本類型

從 .NET 10 開始,macOS 不再支援 OpenSSL 支援的密碼編譯基本類型。 System.Security.Cryptography.AesCcm 和 OpenSSL 特有的類別,例如 System.Security.Cryptography.RSAOpenSsl,現在會在 macOS 上擲回 PlatformNotSupportedException

推出的版本

.NET 10

先前的行為

先前,OpenSSL 特有的類別,例如 System.Security.Cryptography.RSAOpenSsl,如果 OpenSSL 可供使用,則可在 macOS 上運作。

System.Security.Cryptography.AesCcm 如果 OpenSSL 可供使用,則可在 macOS 上運作。

新行為

從 .NET 10 開始,OpenSSL的RSAOpenSsl特有類別即使在macOS上可用,它們仍無法運作,並且會擲回PlatformNotSupportedException例外狀況。

AesCcm 擲回 PlatformNotSupportedException 例外狀況。

破壞性變更的類型

這是 行為變更。

變更的原因

支援 OpenSSL 支援的基本類型源自 .NET Core 1.0,其中 macOS 上的密碼編譯是使用 OpenSSL 實作。 這並不理想,因為最新版的 OpenSSL 不在 macOS 上,而且在 macOS 上取得和設定 OpenSSL 很麻煩。 在 .NET Core 2.0 時間範圍內,密碼編譯已移至 Apple 的內建功能,因此密碼編譯功能「剛剛運作」,而不需要取得任何其他元件。

OpenSsl 為後綴的類型被留作由 OpenSSL 實現,而 AesCcm 在 Apple 的加密函式庫中沒有實作。

在 macOS 上支援這些基於 OpenSSL 的元素變得更加困難,因為 Apple 使從特定路徑載入程式庫的過程變得更具挑戰性,並且這也複雜化了在 macOS 上的軟體散佈。

如果您使用 OpenSSL 支援的基本類型,而沒有任何使用 OpenSSL 的特定意圖,建議使用提供 macOS 實作的處理站:

  • new DSAOpenSsl(...) ->DSA.Create(...)
  • new ECDiffieHellmanOpenSsl(...) ->ECDiffieHellman.Create(...)
  • new ECDsaOpenSsl(...) ->ECDsa.Create(...)
  • new RSAOpenSsl(...) ->RSA.Create(...)

System.Security.Cryptography.AesCcm 在 macOS 上沒有功能等效項目。 請考慮改用不同的密碼編譯基本類型,例如 System.Security.Cryptography.AesGcm

受影響的 API