2016-07-26 56 views
0

我作爲SP工作,最近需要與IDP集成。在IDP的文件中,它會發送一個http post回覆給我。在響應中,有ds:SignatureValue和ds:X509Certificate。有這樣的線程SAML: Why is the certificate within the Signature?,線程只回答如何檢查消息來自誰說的。SAML信任驗證

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
  1. 兩者都是XML數字簽名的元素。 ds:SignatureValue元素包含SAML響應的實際簽名,它是Base64編碼的。 ds:X509Certificate元素是簽名證書(包含公鑰 密鑰和其他IdP的信息),這是Base64編碼。檢查 - XML Digital Signature specification欲瞭解更多信息。
  2. 您可能有來自其元數據的IdP證書。使用IdP 證書對輸入的SAML響應進行簽名,並與來自IdP的ds:SignatureValue的 進行比較。如果這兩個簽名值匹配,那麼您可以確定由您的IdP確實發送了SAML響應。使用OpenSAML實現檢查此code有關如何驗證SP通過SP發送的響應。 (注意:這是我的回購,我使用OpenSAML實施了SAML2.0實施)。
  3. 要生成證書,可以使用各種工具和庫。一個來自Java的 工具是Keytool。檢查谷歌,你會發現很多 教程。
+0

@Study Hard:感謝投票答覆。如果這看起來是正確的,請接受它作爲最佳答案,以便人們發現閱讀問題及其答案很容易。 – Zeigeist

+0

我想知道如何使用IdP證書籤署傳入的SAML響應,並與IdP收到的ds:SignatureValue進行比較。我正在使用OpenSAML,可以獲得斷言,並從響應中獲取Signature。 –

+0

我在第2點添加了代碼參考。請檢查。 – Zeigeist