I\'ve looked at other posts on here regarding this issue and none of them seem to address my situation.
I\'ve been trying to verify a SAML assertion for the last week an
I've spent a lot of time on this issue and then realized that I am not checking the signature with the right certificate.
So I decided to check the certificate I am receiving in the XML response file from Azure:
signedXml.LoadXml((XmlElement)nodeList[0]);
X509Certificate2 serviceCertificate = null;
foreach (KeyInfoClause clause in signedXml.KeyInfo)
{
if (clause is KeyInfoX509Data)
{
if (((KeyInfoX509Data)clause).Certificates.Count > 0)
{
serviceCertificate = (X509Certificate2)((KeyInfoX509Data)clause).Certificates[0];
}
}
}
Then:
bool bTest = signedXml.CheckSignature(serviceCertificate , true);
The bTest
value was finally set to true.