【发布时间】:2016-04-25 18:34:06
【问题描述】:
我尝试了几种解析 SAML 的方法
string raw = txt.Text;
if (raw.Contains('%'))
{
raw = HttpUtility.UrlDecode(raw);
}
byte[] xmlMessageBytes = Convert.FromBase64String(raw);
XmlDocument document = new XmlDocument { PreserveWhitespace = true };
document.LoadXml(Encoding.UTF8.GetString(xmlMessageBytes));
但我在响应中得到随机字符。但是当我使用 Firefox 插件 SAMLTracer 时,它工作得非常好。
非常感谢任何帮助。
【问题讨论】:
-
除非是为了好玩/学习,否则我建议您不要创建自己的 SAML2 实现。关键的安全机制很容易出错(XML 签名包装漏洞在 SAML 实现中很常见)。