Here we all are, faced with figuring out this configuration ... again. Seems to change everytime I get to do it. Here are some learnings I'd like to pass along.
keycloak will not work with ldaps by default, the certificate authority public key must be added to the truststore.
- to get the public key, https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/export-root-certification-authority-certificate, run the following command on your windows ad server in a cmd shell (don't use powershell): certutil -ca.cert ca_name.cer
- now you have your ca public key in a DER formatted base64 text file, you need to load this into the keystore file on the keycloak server, but where is it? in the past default locations were used, then later you had to check the configuration file based on your installation type standalone.xml, standalone-ha.xml, or domain.xml ... here is a file with where to look in the configuration file: https://www.keycloak.org/docs/latest/server_admin/ . search for 'truststore'
- now, you were able to find the location of an existing keystore that was in the configuration file of your installation type, or added to your configuration file where the location is, and you can use the keytool utility to install the cert to your truststore using: keytool -import -file ca_name.cer -keystore path_to_keystore.jks
This has worked for me perfectly in the past, and though I didn't add a section to my configuration file yet, I have not yet had success and I think it may be that keycloak is now using a different jks file specified in the configuration file called https-keystore.jks. I can see the file but don't have the password to see if adding the cert there will get things working.
If I figure it out I'll try to remember to update this posting. In anycase, I'm working towards switching to a kubernetes style installation which has a technique to make this work correctly once and for all ... but, it doesn't. I currently have a ticket in for it and I suspect it used to work, but then something changed, and it broke there too ... just like the latest docker image which I'm currently using.
Here's hoping this configuration becomes a part of keycloak and not something left up to folks to figure out on their own as I believe this tends to push away potential Windows AD users. Good luck out there everyone.