I am having trouble when reading SignedInfo from XML of a signed document, when calling
SignedXml signedXml;
Directory.SetCurrentDirectory(TmpDir);
XmlDocument xmlDoc = new XmlDocument();
foreach(Relationship signature in signs)
{
if(_InMemoryData.ContainsKey(signature.FilePath) || File.Exists(signature.FilePath))
{
using(Stream xmlStream = LoadDataItem(signature.FilePath))
{
xmlDoc.Load(xmlStream);
XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Signature");
if(nodeList.Count == 1)
{
signedXml = new SignedXml(xmlDoc);
signedXml.LoadXml((XmlElement)nodeList[0]); //throws
on line signedXml.LoadXml((XmlElement)nodeList[0]); it is throwing exception with message "System.Security.Cryptography.CryptographicException: Malformed element SignedInfo/Reference".
The only odd thing about this XML that it have 145 recipients. However other software manages to read this without any issues, so I don't think this is an issue.
Searching for exception with "Malformed element..." mostly suggests that element's Id value has numbers in it and that is not allowed. Checked other similar XML files and they all do have numbers in them, so that should not be the case.