2013-01-15 65 views
1

我有一個應用程序,我試圖與Federated Security - 特別是Siteminder集成。我正在使用這裏找到的PHP-SAML工具包:https://github.com/onelogin/php-saml如何使用PHP解密SAML?

我在應用程序中包含了x509證書,並且所有工作都很好,直到在Siteminder環境中打開加密。一旦被打開,我再也不能登錄 - 我收到這樣的信息:無效的SAML響應:無法定位簽名節點

我已經能夠確定的是,SAML斷言發送到來自Siteminder的應用程序被加密。我能夠看到斷言(下面的示例)。不幸的是,我無法弄清楚如何解密該消息,以便我可以解析並在我的應用程序中使用。

<Response xmlns="urn:oasis:names:tc:SAML:2.0:protocol" 
     Destination="{VALUE HERE}" 
     ID="_076e8f69ec4adb3b72f0cc76570527222e37" 
     IssueInstant="2013-01-15T18:18:48Z" 
     Version="2.0" 
     > 
<ns1:Issuer xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion" 
      Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" 
      >{VALUE HERE}</ns1:Issuer> 
<Status> 
    <StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /> 
</Status> 
<ns2:EncryptedAssertion xmlns:ns2="urn:oasis:names:tc:SAML:2.0:assertion"> 
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" 
         Type="http://www.w3.org/2001/04/xmlenc#Element" 
         > 
     <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /> 
     <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
      <xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"> 
       <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /> 
       <xenc:CipherData> 
        <xenc:CipherValue>{VALUE HERE}</xenc:CipherValue> 
       </xenc:CipherData> 
      </xenc:EncryptedKey> 
      <ds:X509Data> 
       <ds:X509Certificate> 
{CERTIFICATE HERE} 
</ds:X509Certificate> 
      </ds:X509Data> 
     </ds:KeyInfo> 
     <xenc:CipherData> 
      <xenc:CipherValue>{VALUE HERE}</xenc:CipherValue> 
     </xenc:CipherData> 
    </xenc:EncryptedData> 
</ns2:EncryptedAssertion> 
</Response> 

如果任何人都可以提供幫助,那將是驚人的。

+0

嗨。你能解密你的XML嗎?我也有同樣的問題 – gkalikapersaud

+0

@ GK123512648是第三方庫的一個選項?如果您可以在服務器上安裝擴展程序,我們的用於PHP的SecureBlackbox庫可以完成這項工作。 –

回答

0

我懷疑這是Onelogin PHP代碼的問題 - 類似的問題是logged,並且Ruby實現有相同的問題。

更新:

如果你想解決這個問題,你需要用證書即一個是在你發送到IP的sp.xml元數據解密此。

從未使用Onlelogin,但會在SimpleSAMLphp代碼中有示例。

+0

這應該是一條評論。 –

+0

這有點太長,太詳細,不能評論。此外,它似乎包含一個解決方案。 :) – duskwuff

+0

謝謝。你提到解密與證書......任何想法我會怎麼做呢?或者我會看SimpleSAMLphp代碼?非常感謝! – Topher

1

要解密SAML消息,您可以提取simplesamlphp庫的一些代碼。

該功能將IIb的_decryptElement/SAML2/utils.php中,解密一個消息元素:

的函數的標頭:

功能_decryptElement(一個DOMElement $的EncryptedData,XMLSecurityKey $ inputKey ,陣列& $黑名單)

(使用空數組爲$黑名單)

檢查在:

http://code.google.com/p/simplesamlphp/source/browse/trunk/lib/SAML2/Utils.php#356

要構建一個DOMElement可以使用的lib/SimpleSAML/Utilities.php這個功能:

formatXMLStringformatDOMElement

http://code.google.com/p/simplesamlphp/source/browse/trunk/lib/SimpleSAML/Utilities.php#1577