System.Security.Cryptography API は、ブラウザで実行されると、実行時に PlatformNotSupportedException をスローします。
変更の説明
以前の .NET バージョンでは、 System.Security.Cryptography API のほとんどは Blazor WebAssembly アプリでは使用できません。 .NET 5 以降、Blazor WebAssembly アプリは完全な .NET 5 API サーフェス領域を対象としますが、ブラウザーサンドボックスの制約のためにすべての .NET 5 API がサポートされているわけではありません。 .NET 5 以降のバージョンでは、サポートされていない System.Security.Cryptography API は、WebAssembly で実行するときに PlatformNotSupportedException をスローします。
ヒント
プラットフォーム互換性アナライザーは、ブラウザー プラットフォームをサポートするプロジェクトをビルドするときに、影響を受ける API への呼び出しにフラグを設定します。 このアナライザーは、.NET 5 以降のアプリで既定で実行されます。
変更の理由
Microsoft は、Blazor WebAssembly 構成の依存関係として OpenSSL を出荷できません。 この問題を回避するために、ブラウザーの SubtleCrypto
API と統合しようとしました。 残念ながら、API を大幅に変更する必要があるため、統合が困難でした。
導入されたバージョン
5.0
推奨されるアクション
現時点では、推奨する適切な回避策はありません。
影響を受ける API
次を除くすべての System.Security.Cryptography API:
System.Security.Cryptography.RandomNumberGenerator
System.Security.Cryptography.IncrementalHash
System.Security.Cryptography.SHA1
System.Security.Cryptography.SHA256
System.Security.Cryptography.SHA384
System.Security.Cryptography.SHA512
System.Security.Cryptography.SHA1Managed
System.Security.Cryptography.SHA256Managed
System.Security.Cryptography.SHA384Managed
System.Security.Cryptography.SHA512Managed
.NET