X509CertificateとPublicKeyの動作が変更されました。 これらのオブジェクトにアルゴリズム パラメーターのないキーが含まれている場合、空の配列ではなく null が返されるようになりました。
導入されたバージョン
.NET 10
以前の動作
以前は、アルゴリズム パラメーターのないキーを含むオブジェクト X509Certificate または PublicKey は、キー アルゴリズム パラメーターにアクセスするときに空の配列を返しました。
byte[] parameters = certificate.GetKeyAlgorithmParameters();
// parameters would be an empty array if no algorithm parameters were present
新しい動作
.NET 10 以降では、アルゴリズム パラメーターのないキーを含むオブジェクトを X509Certificate または PublicKey すると、キー アルゴリズム パラメーターにアクセスするときに null が返されます。
byte[] parameters = certificate.GetKeyAlgorithmParameters();
// parameters will be null if no algorithm parameters are present
破壊的変更の種類
変更の理由
X509Certificate、X509Certificate2、およびPublicKeyクラスは、サブジェクト公開キー情報に関する情報を公開します。
サブジェクト公開キー情報のプロパティの 1 つは、アルゴリズムのパラメーターです。
サブジェクト公開キー情報は、アルゴリズム パラメーターを含める必要はありません。 以前は、これは空のバイト配列として表されていましたが、これは有効な ASN.1 ではありません。 エンコードまたはデコードしようとすると、例外が発生します。 存在しないキー パラメーターをより明確に表すために、 null が返され、アルゴリズム パラメーターを返すメンバーに null 許容値を返す注釈が付けられます。
推奨されるアクション
サブジェクト公開キー情報のアルゴリズム パラメーターに関する情報を返すメンバーにアクセスする場合は、メンバーが null を返し、それに応じて null 値を処理することを想定します。
byte[] parameters = certificate.GetKeyAlgorithmParameters();
if (parameters == null)
{
// Handle the absence of algorithm parameters
}
影響を受ける API
- System.Security.Cryptography.X509Certificates.X509Certificate.GetKeyAlgorithmParameters()
- System.Security.Cryptography.X509Certificates.X509Certificate.GetKeyAlgorithmParametersString()
- System.Security.Cryptography.X509Certificates.PublicKey.PublicKey(Oid, AsnEncodedData, AsnEncodedData)
- System.Security.Cryptography.X509Certificates.PublicKey.EncodedParameters
.NET