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#']")); }
public static void RemoveSignature(XmlElement xmlElement) { XmlElement signatureElement = XmlSignature.GetSignatureElement(xmlElement); if (signatureElement == null) { return; } xmlElement.RemoveChild((XmlNode)signatureElement); }
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); } }
public static bool IsSigned(XmlElement xmlElement) { return(XmlSignature.GetSignatureElement(xmlElement) != null); }