private bool ValidateX509CertificateSignature(XmlDocument SAMLResponse) { XmlNodeList XMLSignatures = SAMLResponse.GetElementsByTagName("Signature", "http://www.w3.org/2000/09/xmldsig#"); // Checking If the Response or the Assertion has been signed once and only once. if (XMLSignatures.Count != 1) { return(false); } SignedXml SignedSAML = new SignedXml(SAMLResponse); SignedSAML.LoadXml((XmlElement)XMLSignatures[0]); // Get X509 Certificate from Cert Store X509Certificate2 SigningCert = CertificateUtility.GetCertificateForSigning("DodgeDerek", StoreName.Root, StoreLocation.LocalMachine); return(SignedSAML.CheckSignature(SigningCert, true)); }