<div dir="ltr">Thanks Bill!<div><br></div><div>What we did was to crate the client in Keycloak by importing the SP metadata file. So the &quot;Encryption Key&quot; and &quot;Signing Key&quot; have the values from the SP&#39;s metadata file already.</div><div>From what I can gather, the values in this part of the client definition in Keycloak, matches the values in the meta data file when looking at the elements:</div><div><br></div><div>&lt;SPSSODescriptor&gt; </div><div>  &lt;KeyDescriptor use=&quot;encryption&quot;&gt;</div><div><span style="line-height:1.5">    &lt;ds:KeyInfo&gt;</span></div><div><div>      &lt;ds:X509Data&gt;</div><div><span style="line-height:1.5">        &lt;ds:X509Certificate&gt;---[Key found in certificate]---</span>&lt;/ds:X509Certificate&gt;</div></div><div><br></div><div>Would this work or am I missing something?</div><div><br></div><div>I can double check that the private key on the SP side actually is correlated with the public one in the meta data file.</div></div><br><div class="gmail_quote"><div dir="ltr">ons. 22. jun. 2016 kl. 15.03 skrev Bill Burke &lt;<a href="mailto:bburke@redhat.com">bburke@redhat.com</a>&gt;:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Once you&#39;ve enabled encryption, you have to go to the &#39;SAML Keys&#39; tab.<br>
There is an Encryption Key at the bottom of that screen.  You can have<br>
Keycloak generate the private key and cert for the SP, or you can import<br>
the SP&#39;s certificate that is stored in a PEM file, JKS, or PKCS12 file.<br>
<br>
On 6/22/16 3:47 AM, Pål Oliver Kristiansen wrote:<br>
&gt; Hi!<br>
&gt;<br>
&gt; We have set up Keycloak as an IDP with a F5 BigIP APM as a SAML SP.<br>
&gt; Everything works well out of the box, but when we activate encryption of<br>
&gt; assertions, we get an error on the<br>
&gt; BigIP side.<br>
&gt;<br>
&gt; So in order to investigate the situation, I&#39;m trying to understand the<br>
&gt; process of SAML assertion response encryption.<br>
&gt; And I am a bit confused when reading the Keycloak documentation and<br>
&gt; comparing that to what I see in the Keycloak admin console.<br>
&gt; Here is what I mean; in the documentation<br>
&gt; (<a href="https://keycloak.github.io/docs/userguide/keycloak-server/html/saml.html" rel="noreferrer" target="_blank">https://keycloak.github.io/docs/userguide/keycloak-server/html/saml.html</a>),<br>
&gt; activating<br>
&gt; assertion response encryption is described like this:<br>
&gt;<br>
&gt; &quot;Encrypt Assertions<br>
&gt; Encrypt assertions in SAML documents with the realm&#39;s private key. The<br>
&gt; AES algorithm is used with a key size of 128 bits.&quot;<br>
&gt;<br>
&gt; But in the admin console (under clients) it is described like this in<br>
&gt; the tooltip:<br>
&gt;<br>
&gt; &quot;Encrypt Assertions<br>
&gt; Should SAML assertions be encrypted with client&#39;s public key using AES?&quot;<br>
&gt;<br>
&gt; So basically, which key is used for encrypting the assertion response?<br>
&gt;<br>
&gt; I have inspected the actual HTTP post and it looks something like this:<br>
&gt;<br>
&gt; &lt;samlp:Response&gt;<br>
&gt; ...<br>
&gt;   &lt;saml:EncryptedAssertion&gt;<br>
&gt;     &lt;xenc:EncryptedData xmlns:xenc=&quot;<a href="http://www.w3.org/2001/04/xmlenc#" rel="noreferrer" target="_blank">http://www.w3.org/2001/04/xmlenc#</a>&quot;<br>
&gt; Type=&quot;<a href="http://www.w3.org/2001/04/xmlenc#Element" rel="noreferrer" target="_blank">http://www.w3.org/2001/04/xmlenc#Element</a>&quot;&gt;<br>
&gt;       &lt;xenc:EncryptionMethod<br>
&gt; Algorithm=&quot;<a href="http://www.w3.org/2001/04/xmlenc#aes128-cbc" rel="noreferrer" target="_blank">http://www.w3.org/2001/04/xmlenc#aes128-cbc</a>&quot;/&gt;<br>
&gt;         &lt;ds:KeyInfo xmlns:ds=&quot;<a href="http://www.w3.org/2000/09/xmldsig#" rel="noreferrer" target="_blank">http://www.w3.org/2000/09/xmldsig#</a>&quot;&gt;<br>
&gt;           &lt;xenc:EncryptedKey&gt;<br>
&gt;             &lt;xenc:EncryptionMethod<br>
&gt; Algorithm=&quot;<a href="http://www.w3.org/2001/04/xmlenc#rsa-1_5" rel="noreferrer" target="_blank">http://www.w3.org/2001/04/xmlenc#rsa-1_5</a>&quot;/&gt;<br>
&gt;             &lt;xenc:CipherData&gt;<br>
&gt;               &lt;xenc:CipherValue&gt;---[block of cipher<br>
&gt; text]---&lt;/xenc:CipherValue&gt;<br>
&gt;             &lt;/xenc:CipherData&gt;<br>
&gt;           &lt;/xenc:EncryptedKey&gt;<br>
&gt;         &lt;/ds:KeyInfo&gt;<br>
&gt;       &lt;xenc:CipherData&gt;<br>
&gt;         &lt;xenc:CipherValue&gt;---[block of cipher text]---&lt;/xenc:CipherValue&gt;<br>
&gt;       &lt;/xenc:CipherData&gt;<br>
&gt;     &lt;/xenc:EncryptedData&gt;<br>
&gt;   &lt;/saml:EncryptedAssertion&gt;<br>
&gt; &lt;/samlp:Response&gt;<br>
&gt;<br>
&gt; So it at least looks like the key to decrypt the encrypted response is<br>
&gt; included. It is encrypted using RSA, but with which key?<br>
&gt; My understanding was something like this:<br>
&gt;<br>
&gt; 1. The encryption of a SAML assertion response is done using AES-128,<br>
&gt; with some key.<br>
&gt; 2. The key is added alongside the encrypted assertion response and<br>
&gt; encrypted using the SP&#39;s public key.<br>
&gt; 3. The SP receives the encrypted assertion response and the encrypted<br>
&gt; key, decrypts the key using its&#39; private key and uses<br>
&gt; this decrypted key to decrypt the actual assertion response.<br>
&gt;<br>
&gt; Is this generally correct?<br>
&gt;<br>
&gt; The error we get from BigIP is this: &quot;failed to process encrypted<br>
&gt; assertion, error: RSA decrypt&quot;<br>
&gt; Which leads me to think that maybe the decryption of the included key<br>
&gt; did not work out.<br>
&gt; Any ideas or tips to how to approach this?<br>
&gt;<br>
&gt; Thanks!<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; keycloak-user mailing list<br>
&gt; <a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt;<br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote></div>