We’re trying to connect keycloak to ldap over ssl. We followed keycloak documentation from this link and this link for adding the spi standalone.xml as can be seen below. There’s no problem on testing the connection url but it is failing on testing authentication. The seen error from the logs is as below. Is there a configuration that might be missed?
SunCertPathBuilderException: unable to find valid certification path to requested target
@ema07cqc
what worked for me was, I copied my Certs from my CA (which was on my MSAD), then added them to my java keystore (cacerts) on my CentOS 7 machine. I did try creating my own keystore, but for some reason ansible failed to use it. It might have something to do with my Nginx reverse proxy.
Certificate validation is about validating that an server certificate is known. Certificate offered by server is known when it certificate chain can be checked till known trusted certificate. So, for this you have 2 options:
Add a common root certificate;
Add each ones final certificate (if you use all DCs).
Thanks for your reply. Im still trying to figure out how to make this works. CONTOSO is my domain
Im trying to connect a Keycloak Realm to LDAPS.
LDAP works just fine, but LDAPS not.
created a CA.crt and imported to all my DCs
tested CA.crt the LDAPS connection with openssl and it connect OK to all DCs openssl s_client -connect DC1.contoso.local:636 -CAfile /mnt/ssl-ad-2020/LDAPS/ca.crt
returns OK openssl s_client -connect DC2.contoso.local:636 -CAfile /mnt/ssl-ad-2020/LDAPS/ca.crt
returns OK openssl s_client -connect DC3.contoso.local:636 -CAfile /mnt/ssl-ad-2020/LDAPS/ca.crt
returns OK
inside keycloak container, i generated a ¨custom¨ keystore with the command keytool -import -alias contoso.local -keystore /var/lib/keycloak/data/certs/ldaps/contoso-truststore.jks -file /var/lib/keycloak/data/certs/ldaps/contosoLDAPS.crt
added this lines to keycloak/configuration/standalone.xml
16:30:51,778 ERROR [org.keycloak.services] (default task-5) KC-SERVICES0055: Error when authenticating to LDAP: contoso.local:636: javax.naming.CommunicationException: contoso.local:636 [Root exception is java.net.SocketException: Connection reset by peer (connect failed)]
and
16:30:53,963 ERROR [org.keycloak.services] (default task-5) KC-SERVICES0055: Error when authenticating to LDAP: Could not negotiate TLS: javax.naming.AuthenticationException: Could not negotiate TLS
I´m working with keycloak 13.0.1 over ubuntu 18.04. It´s working fine but I want to secure the LDAP connection using LDAPS over StartTLS
The server give me the following message:
[ERROR [org.keycloak.services] (default task-15) KC-SERVICES0055: Error when authenticating to LDAP: Could not negotiate TLS: javax. naming.AuthenticationException: Could not negotiate TLS]
I tried all of the solutions mentioned in this conversation. Could be a the problem with the certificate? but i have the https working, Is not the same certificate?
When hay try to check the LDAP certificate using
openssl s_client -connect [ipserver]:636
I recieve
Verify return code: 20 (unable to get local issuer certificate)
read:errno=104