title: SignedXml.LoadXml() throws a CryptographicException
body: <p>I have a connection to an external WebService which was running flawless for ages until medio may 2018. Suddenly I started getting a CryptographicException with the message "Malformed XML Signature". My investigation tells me the following:</p>
  
  <p>The exception is thrown from the line LoadXml(signature); in a class that inherits from System.Security.Cryptography.Xml.SignedXml</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public bool CheckAssertionSignature()
      {
          if (Xml == null || Xml.DocumentElement == null)
              return false;
  
          var xmlass = Xml.DocumentElement.LocalName == "Assertion" ? Xml.DocumentElement : Xml.GetElementsByTagName("Assertion", Namespaces.Saml)[0] as XmlElement;
          var signature = xmlass.GetElementsByTagName("Signature", Namespaces.Ds)[0] as XmlElement;
          if (signature == null) return false;
          LoadXml(signature);
          var cert = KeyInfo.Cast&lt;KeyInfoX509Data&gt;().Select(d =&gt; d.Certificates[0] as X509Certificate2).FirstOrDefault(c =&gt; c != null);
  
          return cert != null &amp;&amp; CheckSignature(cert, true);
      }
  </code></pre>
  
  <p>What I've learned so far is:
  A colleague and I have tested the code locally on two different versions of windows 10. His version is newer than mine. He gets the error and I don't.</p>
  
  <p>The xml processed by the code is identical</p>
  
  <p>The error started on the 16th of may 2018 and on that date the server installed this security update <a href="https://support.microsoft.com/da-dk/help/4099635/security-and-quality-rollup-for-net-framework-3-5-4-5-2-4-6-4-6-1-4-6" rel="nofollow noreferrer">https://support.microsoft.com/da-dk/help/4099635/security-and-quality-rollup-for-net-framework-3-5-4-5-2-4-6-4-6-1-4-6</a></p>
  
  <p>We know that a similar update earlier caused a similar problem:
  <a href="https://support.microsoft.com/en-us/help/3148821/after-you-apply-security-update-3141780-net-framework-applications-enc" rel="nofollow noreferrer">https://support.microsoft.com/en-us/help/3148821/after-you-apply-security-update-3141780-net-framework-applications-enc</a></p>
  
  <p>Has anyone an idea about how to solve this problem (and is anybody else experiencing the problem)?</p>
  
  <p>PS. The code is running on a Windows srv 2012 R2 and the problem also exists on a  windows srv 2016</p>