CryptographicException: Could not create hash algorithm object

Marc George 171 Reputation points
2022-05-10T12:41:01.56+00:00

Since upgrading/migrating from .NET 4.3.1 to 6.0 and targeting a Windows Server 7 app service on Azure, I have been encountering the above error when making a call to System.Security.Cryptography.Xml.SignedXml.ComputeSignature(). The cryptography assemblies are now v6.0.0.0.

Remote debugging, I think it is the related to the results of the call to SHA256.Create() which is the DigestAlgorithm parameter in the call. It doesn't have the same content pattern as the others. The parameter values being passed are:

KeyAlgorithm: *"System.Security.Cryptography.RSACryptoServiceProvider, System.Security.Cryptography.Csp, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"*

DigestAlgorithm: *"System.Security.Cryptography.SHA256+Implementation"*

FormatterAlgorithm: *"System.Security.Cryptography.RSAPKCS1SignatureFormatter, System.Security.Cryptography.Algorithms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"*

DeformatterAlgorithm: *"System.Security.Cryptography.RSAPKCS1SignatureDeformatter, System.Security.Cryptography.Algorithms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"*

What should the expected value of the DigestAlgorithm be? Something similar to the others?

There have been other reports of issues with the function with the upgrade to 6. Anyone else? Solutions?

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,567 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,601 questions
{count} votes