I am getting the valid SAML response from the vendor and I just want to validate SAML Assertion.
Below is the SAML response and I have mask few things with xxxxxxxxxxxxxxxxxxxxxx due to vendor concern.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxx
I have tried the below code in the .NET 3.5 web application and I am always getting the invalid signature message from the code. Please have a look in the code and suggest me.
Thanks in Advance.
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("SAML.xml"));
SignedXml signer = new CustomIdSignedXml(doc);
signer.AddReference(new Reference("#_d4559638-3abf-4433-9fad-b10f8a950351"));
// _d4559638-3abf-4433-9fad-b10f8a950351 is used as reference to DigestMethod & DigestValue.
signer.SigningKey = new RSACryptoServiceProvider();
signer.ComputeSignature();
string s = signer.GetXml().OuterXml;
SignedXml verifier = new CustomIdSignedXml(doc);
verifier.LoadXml(signer.GetXml());
if (verifier.CheckSignature(signer.SigningKey))
Response.Write("Signature verified");
else
Response.Write("Invalid signature");
Stephen OberauerPosted Oct 14, 2015, 10:52 AM
Jiteendra SampathiraoPosted Jun 30, 2011, 8:18 AM
refer these links:
http://www.madaboutcode.com/blog/post/2010/8/8/12/Validating-a-SAML-assertion-in-net
http://xml.sys-con.com/node/1404876