Malformed reference element: Digital Signature

2

I ended up having the same problem about a post already done here, however come a doubt next to what was posted in the article. What windows update would be to remove from the ones mentioned in this article ? (removal would be a palliative until the problem is solved)

Out of doubt about the article, follow the code that I'm having problems with.

public void AssinarElementos(XmlDocument Document, X509Certificate2 x509, string ParentElementName, string ElementName, string AttributeName)
    {

        XmlElement elInf;
        string elInfID;
        SignedXml elSigned;
        RSACryptoServiceProvider Key;
        KeyInfo keyInfo = new KeyInfo();
        // Retira chave privada ligada ao certificado
        Key = ((RSACryptoServiceProvider)(x509.PrivateKey));
        keyInfo.AddClause(new KeyInfoX509Data(x509));
        foreach (XmlElement ele in Document.GetElementsByTagName(ParentElementName))
        {
            elInf = ((XmlElement)(ele.GetElementsByTagName(ElementName)[(ele.GetElementsByTagName(ElementName).Count - 1)]));
            elInfID = elInf.Attributes.GetNamedItem(AttributeName).Value;
            elSigned = new SignedXml(elInf);

            // Seta chaves
            elSigned.SigningKey = Key;
            elSigned.KeyInfo = keyInfo;
            //  Cria referencia
            Reference reference = new Reference();
            reference.Uri = ("#" + elInfID);
            //  Adiciona tranformacao a referencia
            reference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
            reference.AddTransform(new XmlDsigC14NTransform(false));
            //  Adiciona referencia ao xml
            elSigned.AddReference(reference);
            //  Calcula Assinatura
            elSigned.ComputeSignature();
            // Adiciona assinatura
            ele.AppendChild(Document.ImportNode(elSigned.GetXml(), true));
        }
    }

A Elemento de referência mal formado. error is generated on the line where elSigned.ComputeSignature(); will run (I ran a test on a machine with windows 10 and it worked perfectly).

One of the answers in

asked by anonymous 13.04.2016 / 21:00

1 answer

2

The update of windows 7 to be removed (palliative solution), is KB3135983 .

In case she does this new security "request" in xml now.

It is confirmed that the ID needs to start with letter only, and can not contain special characters in its ID.

If you use the palliative solution, it is recommended that you also hide the update to avoid possible returns on the machine. Follow the image in windows update allowing to disable the specific update (even in automatic mode).

Obs: It is worth mentioning that the removal of the update is only for the system to continue in its operation until it is updated, removing the problem later, obtaining the least impact to the end user (directly or indirectly). >

    
02.05.2016 / 20:23