SignedXml checksignature returns false

前端 未结 4 796
长发绾君心
长发绾君心 2021-02-08 12:53

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

4条回答
  •  囚心锁ツ
    2021-02-08 13:25

    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.

提交回复
热议问题