【问题标题】:SAML trust verficationSAML 信任验证
【发布时间】:2016-11-30 08:30:54
【问题描述】:

我是一名 SP,最近需要与 IDP 集成。在 IDP 的文档中,它会向我发送一个 http post 响应。在响应中,有 ds:SignatureValue 和 ds:X509Certificate。有一个类似SAML: Why is the certificate within the Signature?的线程,线程只回答如何检查消息是来自它所说的是谁。

1) ds:SignatureValue 和 ds:X509Certificate 是什么意思?

2) 如何确保回复来自我的 IDP?我的意思是,如果黑客知道我的 http post 地址,他们可以轻松地向我的应用程序发送类似的 http post 请求。我发现http请求头中有一个referer,这样可以安全地验证来自我的IDP的请求吗?

3) IDP 要求我发送 SP 公共签名证书,格式应为 DER 编码的二进制 X.509 (*.CER)。如何创建公开的公开签名证书?

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
 <ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
  <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
  <ds:Reference URI="#_2152811999472b94a0e9644dbc932cc3" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
   <ds:Transforms xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
     <ec:InclusiveNamespaces PrefixList="ds saml samlp xs" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    </ds:Transform>
   </ds:Transforms>
   <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"/>
   <ds:DigestValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">bW1Os7+WykqRt5h0mdv9o3ZF0JI=</ds:DigestValue>
  </ds:Reference>
 </ds:SignedInfo>
 <ds:SignatureValue xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
SignatureValue </ds:SignatureValue>
 <ds:KeyInfo>
  <ds:X509Data>
   <ds:X509Certificate>X509 certification</ds:X509Certificate>
  </ds:X509Data>
 </ds:KeyInfo>
</ds:Signature>

【问题讨论】:

    标签: saml saml-2.0


    【解决方案1】:
    1. 两者都是 XML 数字签名的元素。 ds:SignatureValue 元素包含 SAML 响应的实际签名,它是 Base64 编码的。 ds:X509Certificate 元素是签名证书(包含公共 密钥和其他 IdP 的信息),它是 Base64 编码的。检查 - XML Digital Signature specification 了解更多信息。
    2. 您可能拥有来自其元数据的 IdP 证书。使用 IdP 用于签署传入 SAML 响应并与之比较的证书 从 IdP 收到 ds:SignatureValue。如果这两个签名值匹配,那么您可以确保您的 IdP 确实发送了 SAML 响应。检查此code,了解如何使用 OpenSAML 实现验证 SP 从 IdP 发送的响应。 (注意:这是我的仓库,我使用 OpenSAML 实现了 SAML2.0 实现)。
    3. 要生成证书,可以使用各种工具和库。一个已知的 Java 的工具是 Keytool。在谷歌上查一下,你会发现很多 这方面的教程。

    【讨论】:

    • @Study Hard:感谢您投票给我的答案。如果这似乎是正确的,请接受它作为最佳答案,以便人们可以轻松阅读问题及其答案。
    • 我想知道如何使用 IdP 证书对传入的 SAML 响应进行签名并与从 IdP 收到的 ds:SignatureValue 进行比较。我正在使用 OpenSAML,并且可以从响应中获取断言和签名。
    猜你喜欢
    • 2021-11-04
    • 2014-06-19
    • 2017-05-14
    • 2014-12-20
    • 1970-01-01
    • 2016-09-07
    • 2015-05-19
    • 2021-04-15
    • 1970-01-01
    相关资源
    最近更新 更多