-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
We had an issue with XML Signing in a .NET Framework application on Windows (System.Security.Cryptography.CryptographicException:
Malformed element SignedInfo/Reference.) and successfully used a workaround setting the registry key SignedXmlMaxReferencesPerSignedInfo:
After some setting up and debuging system libraries I found out where it throws the excpetion and apperantly by default it only allow 100 recipients. To change that, I needed to add a new registry key named "SignedXmlMaxReferencesPerSignedInfo" with DWord value to be greater than 145 in my case to "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\Security" and it started working.
SignedXml.LoadXML((XmlElement)nodeList[0]) throwing "Malformed element SignedInfo/Reference"
We planned on migrating the application to .NET 10. But in we found that in .NET 10 the limit is hard-coded to 100 References, which would make it impossible to migrate while using System.Security.Cryptography.Xml.
Is it possible to make this limit configurable again?
Check located in SignedInfo.cs:
https://github.com/dotnet/runtime/blob/v10.0.2/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/SignedInfo.cs#L260
Limit defined in Utils.cs: https://github.com/dotnet/runtime/blob/v10.0.2/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Utils.cs#L763