Example #1
0
        public static XmlElement GetCertificateElement(XmlElement xmlElement)
        {
            XmlElement signatureElement = XmlSignature.GetSignatureElement(xmlElement);

            if (signatureElement == null)
            {
                return((XmlElement)null);
            }
            return((XmlElement)signatureElement.SelectSingleNode("//*[local-name(.) = 'X509Certificate' and namespace-uri(.) = 'http://www.w3.org/2000/09/xmldsig#']"));
        }
Example #2
0
        public static void RemoveSignature(XmlElement xmlElement)
        {
            XmlElement signatureElement = XmlSignature.GetSignatureElement(xmlElement);

            if (signatureElement == null)
            {
                return;
            }
            xmlElement.RemoveChild((XmlNode)signatureElement);
        }
Example #3
0
 public static bool Verify(XmlElement xmlElement, AsymmetricAlgorithm signingKey, SignedXml signedXml)
 {
     try
     {
         XmlElement signatureElement = XmlSignature.GetSignatureElement(xmlElement);
         if (signatureElement == null)
         {
             throw new SamlSignatureException("The XML does not contain a signature.");
         }
         signedXml.LoadXml(signatureElement);
         return(signingKey == null?signedXml.CheckSignature() : signedXml.CheckSignature(signingKey));
     }
     catch (Exception ex)
     {
         throw new SamlSignatureException("Failed to verify the XML signature.", ex);
     }
 }
Example #4
0
 public static bool IsSigned(XmlElement xmlElement)
 {
     return(XmlSignature.GetSignatureElement(xmlElement) != null);
 }