<div dir="ltr"><div>Hi!</div><div><br></div><div>We have set up Keycloak as an IDP with a F5 BigIP APM as a SAML SP.</div><div>Everything works well out of the box, but when we activate encryption of assertions, we get an error on the</div><div>BigIP side.</div><div><br></div><div>So in order to investigate the situation, I&#39;m trying to understand the process of SAML assertion response encryption.</div><div>And I am a bit confused when reading the Keycloak documentation and comparing that to what I see in the Keycloak admin console.</div><div>Here is what I mean; in the documentation (<a href="https://keycloak.github.io/docs/userguide/keycloak-server/html/saml.html">https://keycloak.github.io/docs/userguide/keycloak-server/html/saml.html</a>), activating</div><div>assertion response encryption is described like this:</div><div><br></div><div>&quot;Encrypt Assertions</div><div>Encrypt assertions in SAML documents with the realm&#39;s private key. The AES algorithm is used with a key size of 128 bits.&quot;</div><div><br></div><div>But in the admin console (under clients) it is described like this in the tooltip:</div><div><br></div><div>&quot;Encrypt Assertions</div><div>Should SAML assertions be encrypted with client&#39;s public key using AES?&quot;</div><div><br></div><div>So basically, which key is used for encrypting the assertion response?</div><div><br></div><div>I have inspected the actual HTTP post and it looks something like this:</div><div><br></div><div>&lt;samlp:Response&gt;</div><div>...</div><div>  &lt;saml:EncryptedAssertion&gt;</div><div>    &lt;xenc:EncryptedData xmlns:xenc=&quot;<a href="http://www.w3.org/2001/04/xmlenc#">http://www.w3.org/2001/04/xmlenc#</a>&quot; Type=&quot;<a href="http://www.w3.org/2001/04/xmlenc#Element">http://www.w3.org/2001/04/xmlenc#Element</a>&quot;&gt;</div><div>      &lt;xenc:EncryptionMethod Algorithm=&quot;<a href="http://www.w3.org/2001/04/xmlenc#aes128-cbc">http://www.w3.org/2001/04/xmlenc#aes128-cbc</a>&quot;/&gt;</div><div>        &lt;ds:KeyInfo xmlns:ds=&quot;<a href="http://www.w3.org/2000/09/xmldsig#">http://www.w3.org/2000/09/xmldsig#</a>&quot;&gt;</div><div>          &lt;xenc:EncryptedKey&gt;</div><div>            &lt;xenc:EncryptionMethod Algorithm=&quot;<a href="http://www.w3.org/2001/04/xmlenc#rsa-1_5">http://www.w3.org/2001/04/xmlenc#rsa-1_5</a>&quot;/&gt;</div><div>            &lt;xenc:CipherData&gt;</div><div>              &lt;xenc:CipherValue&gt;---[block of cipher text]---&lt;/xenc:CipherValue&gt;</div><div>            &lt;/xenc:CipherData&gt;</div><div>          &lt;/xenc:EncryptedKey&gt;</div><div>        &lt;/ds:KeyInfo&gt;</div><div>      &lt;xenc:CipherData&gt;</div><div>        &lt;xenc:CipherValue&gt;---[block of cipher text]---&lt;/xenc:CipherValue&gt;</div><div>      &lt;/xenc:CipherData&gt;</div><div>    &lt;/xenc:EncryptedData&gt;</div><div>  &lt;/saml:EncryptedAssertion&gt;</div><div>&lt;/samlp:Response&gt;</div><div><br></div><div>So it at least looks like the key to decrypt the encrypted response is included. It is encrypted using RSA, but with which key?</div><div>My understanding was something like this:</div><div><br></div><div>1. The encryption of a SAML assertion response is done using AES-128, with some key.</div><div>2. The key is added alongside the encrypted assertion response and encrypted using the SP&#39;s public key.</div><div>3. The SP receives the encrypted assertion response and the encrypted key, decrypts the key using its&#39; private key and uses</div><div>this decrypted key to decrypt the actual assertion response.</div><div><br></div><div>Is this generally correct?</div><div><br></div><div>The error we get from BigIP is this: &quot;failed to process encrypted assertion, error: RSA decrypt&quot;</div><div>Which leads me to think that maybe the decryption of the included key did not work out.</div><div>Any ideas or tips to how to approach this?</div><div><br></div><div>Thanks!</div></div>