SAML信任验证

时间:2016-07-26 15:32:54

标签: saml saml-2.0

我作为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帖子地址,他们可以轻松地向我的应用程序发送类似的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>

1 个答案:

答案 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。在Google上查看,你会发现很多 关于此的教程。