在SAML4.0中SignedXmlDoc.CheckSignature总是返回false你能在验证.NET签名时帮助我吗
CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
X509Certificate2 cert = new X509Certificate2();
string text = System.IO.File.ReadAllText(@"D:\TFS\KCWBB\Dev-2\Source\KC.WEM.ITGSMI.Web\File\sig.cert");
cert.Import(Encoding.UTF8.GetBytes(text));
XmlNodeList XMLSignatures = xnlDoc.GetElementsByTagName("Signature", "http://www.w3.org/2000/09/xmldsig#");
KeyInfo key = new KeyInfo();
KeyInfoX509Data data = new KeyInfoX509Data(cert);
key.AddClause(data);
// Checking If the Response or the Assertion has been signed once and only once.
if (XMLSignatures.Count == 0) return false;
var signedXmlDoc = new SignedXml(xnlDoc);
signedXmlDoc.LoadXml((XmlElement)XMLSignatures[0]);
if (cert == null)
{
return false;
}
return signedXmlDoc.CheckSignature(cert,true);发布于 2017-03-08 04:14:57
你看过这个吗:SignedXml.CheckSignature fails in .NET 4 but it works in .NET 3.5, 3 or 2
也可能是同样的问题。因为在你的代码中看不到任何关于大炮的东西。
https://stackoverflow.com/questions/42625048
复制相似问题