title: How can I decrypt SAML with PHP?
body: <p>I have an application that I'm trying to integrate with Federated Security -- specifically, Siteminder.  I'm using the PHP-SAML toolkit found here: <a href="https://github.com/onelogin/php-saml" rel="nofollow">https://github.com/onelogin/php-saml</a></p>
  
  <p>I have the x509 cert included in the application, and all works well, until encryption is turned on in the Siteminder environment.  Once that was turned on, I was no longer able to log in -- I received this message: <strong>Invalid SAML response: Cannot locate Signature Node</strong></p>
  
  <p>I've been able to determine that the SAML assertion being sent to the application, from Siteminder, is encrypted.  I'm able to see the assertion (sample included below).  Unfortunately, I can't figure out how to decrypt that message, so that I can then parse and use in my application.</p>
  
  <pre><code>&lt;Response xmlns="urn:oasis:names:tc:SAML:2.0:protocol"
        Destination="{VALUE HERE}"
        ID="_076e8f69ec4adb3b72f0cc76570527222e37"
        IssueInstant="2013-01-15T18:18:48Z"
        Version="2.0"
        &gt;
  &lt;ns1:Issuer xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion"
              Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
              &gt;{VALUE HERE}&lt;/ns1:Issuer&gt;
  &lt;Status&gt;
      &lt;StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /&gt;
  &lt;/Status&gt;
  &lt;ns2:EncryptedAssertion xmlns:ns2="urn:oasis:names:tc:SAML:2.0:assertion"&gt;
      &lt;xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
                          Type="http://www.w3.org/2001/04/xmlenc#Element"
                          &gt;
          &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" /&gt;
          &lt;ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"&gt;
              &lt;xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"&gt;
                  &lt;xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /&gt;
                  &lt;xenc:CipherData&gt;
                      &lt;xenc:CipherValue&gt;{VALUE HERE}&lt;/xenc:CipherValue&gt;
                  &lt;/xenc:CipherData&gt;
              &lt;/xenc:EncryptedKey&gt;
              &lt;ds:X509Data&gt;
                  &lt;ds:X509Certificate&gt;
  {CERTIFICATE HERE}
  &lt;/ds:X509Certificate&gt;
              &lt;/ds:X509Data&gt;
          &lt;/ds:KeyInfo&gt;
          &lt;xenc:CipherData&gt;
              &lt;xenc:CipherValue&gt;{VALUE HERE}&lt;/xenc:CipherValue&gt;
          &lt;/xenc:CipherData&gt;
      &lt;/xenc:EncryptedData&gt;
  &lt;/ns2:EncryptedAssertion&gt;
  &lt;/Response&gt;
  </code></pre>
  
  <p>If anyone can help, that would be amazing.</p>