public void ValidateSignature(XmlDocument xmlDoc) { X509Certificate2 cert = _certificateStore.DBSignatureCertificate(); RSACryptoServiceProvider rsaSignChecker = (RSACryptoServiceProvider)cert.PublicKey.Key; SignedXmlWithId signedXml = new SignedXmlWithId(xmlDoc); var signatureNodes = xmlDoc.GetElementsByTagName("Signature"); if (signatureNodes.Count != 1) { throw new SignatureVerificationFailedException("Response message does not contain a signature"); } var signature = signatureNodes[0] as XmlElement; signedXml.LoadXml(signature); if (signedXml.CheckSignature(rsaSignChecker) == false) { throw new SignatureVerificationFailedException("Signature in response message could not be varified"); } }
public void Can_load_db_signing() { Assert.IsNotNull(sut.DBSignatureCertificate()); }