SignedXml checksignature returns false

前端 未结 4 802
长发绾君心
长发绾君心 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:44

    Had a similar issue with Saml as Timores. The Saml needed to be decoded from Base64 but first i used:

    var saml = System.Text.Encoding.Default.GetString(Convert.FromBase64String(samlToken))
    

    But this used ASCII decoding and had trouble with special characters. Which means the XML was slightly different from when it was signed and that is why it failed. Changed it to:

    var saml = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(samlToken))
    

    and it worked for all cases.

    So be sure that you are using the right encoding!

提交回复
热议问题