How can i validate in .Net C# a SAML signature created in Java?
Here is the SAML Signature that i get from Java:
I tried this:
public bool VerifySignature() { X509Certificate2 certificate = null;
XmlDocument doc = new XmlDocument(); XmlElement xmlAssertionElement = this.GetXml(doc); doc.AppendChild(xmlAssertionElement);
// Create a new SignedXml object and pass it // the XML document class. SamlSignedXml signedXml = new SamlSignedXml(xmlAssertionElement);
// Get signature XmlElement xmlSignature = this.Signature; if (xmlSignature == null) { return false; }
// Load the signature node. signedXml.LoadXml(xmlSignature); // Get the certificate used to sign the assertion if information about this // certificate is available in the signature of the assertion. foreach (KeyInfoClause clause in signedXml.KeyInfo) { if (clause is KeyInfoX509Data) { if (((KeyInfoX509Data)clause).Certificates.Count > 0) { certificate = (X509Certificate2)((KeyInfoX509Data)clause).Certificates[0]; }
} }
if (certificate == null) { return false; }
return signedXml.CheckSignature(certificate, true); }
|
It valides the signature of a SAML signed in .Net but not of this Java one.
If someone knows please help!!
Thank you very much.