03. 07. 2025 Alessandro Paoli NetEye, Unified Monitoring

Configuring Keycloak with LDAP and TLS Certificate (LDAPS) in NetEye

In this article I’ll guide you step-by-step through configuring Keycloak to connect to an LDAP server using a secure LDAPS (SSL/TLS) connection, with support for certificates signed by either internal or self-signed Certificate Authorities. This is especially useful in enterprise environments using Active Directory or a centralized LDAP server.

This configuration is particularly relevant for environments using NetEye, as NetEye relies on Keycloak for centralized authentication and supports integration with LDAP directories for user federation and access control.

Requirements

  • Access to an LDAP server (e.g., OpenLDAP or Microsoft AD)
  • Root/intermediate certificate used by the LDAP server
  • Root/sudo access on the system running Keycloak
  • A working NetEye environment that uses Keycloak as its identity provider

1. Obtain the LDAP Server Certificate

Extract the LDAP server certificate (or the root CA that signed it). If you don’t already have it, you can retrieve it using openssl:

openssl s_client -connect ldap.example.com:636 -showcerts

Copy the certificate (or the full chain) and save it to a file, for example ldap-ca.pem.

2. Import the Certificate into the Java Truststore

Keycloak uses Java, which verifies certificates through the default truststore. To import the certificate:

sudo keytool -importcert -trustcacerts -alias ldap-ca \
  -file ldap-ca.pem -keystore /etc/pki/java/cacerts -storepass changeit

Verify the import:

keytool -list -keystore /etc/pki/java/cacerts -storepass changeit | grep ldap-ca

changeit is the default truststore password. Ensure the truststore path matches your distribution.

Note: To change the Java keystore password, use the following command:

keytool -storepasswd -keystore /etc/pki/java/cacerts

You will be prompted to enter the old password (changeit) and the new one.

3. Restart Keycloak

Apply the changes:

sudo systemctl restart keycloak

4. Configure the LDAP Provider in Keycloak

  1. Log in to the Keycloak admin console
  2. Select the desired realm (usually preconfigured in NetEye)
  3. Navigate to User Federation > Add provider > ldap
  4. Fill in the main fields:
FieldValue
UI display nameCustom name
VendorActive Directory
Connection URLldaps://ldap.example.com:636
Bind typesimple
Bind DNcn=admin,dc=example,dc=com
Bind CredentialLDAP password
Users DNou=Users,dc=example,dc=com
Edit ModeREAD_ONLY
Use Truststore SPIalways

  5. Save
  6. Click Synchronize all users to test the connection

Once synchronized, LDAP users will be visible in Keycloak and can authenticate into NetEye via SSO

5. Common Troubleshooting

Error: SSLHandshakeException

  • The server certificate is invalid or not present in the truststore
  • The certificate chain is incomplete (missing root or intermediate)
  • Wrong port or protocol (e.g., ldaps:// on port 389)

Solutions:

  • Verify with:
openssl s_client -connect ldap.example.com:636 -showcerts
  • Check the logs: /opt/keycloak/logs/server.log or journalctl -fu keycloak
  • Ensure the certificate’s CN or SAN matches the LDAP hostname

6. Final Test

Try logging into Keycloak with an LDAP user. If everything is configured correctly, authentication should succeed.

Then log into NetEye using the same user: you should be authenticated via Keycloak and redirected successfully.

Conclusion

Connecting Keycloak to an LDAP server via LDAPS significantly enhances authentication infrastructure security. This is especially important in NetEye environments, where centralized identity and access management is critical.

These Solutions are Engineered by Humans

Did you find this article interesting? Does it match your skill set? Programming is at the heart of how we develop customized solutions. In fact, we’re currently hiring for roles just like this and others here at Würth Phoenix.

Alessandro Paoli

Alessandro Paoli

My name is Alessandro Paoli and I've been a Technical Consultant at Wurth Phoenix since May 2024. I've always had a great passion for IT and since 2004 it has also become my job. In 2015 I found my role in the field, monitoring. I have had the opportunity to use various monitoring products, both open source and proprietary, I have worked on numerous projects from small businesses to global companies. I am married and have 2 wonderful daughters. My passions are travel, cinema, games (video and board) and comics, and every now and then I manage to indulge in a few days of sport (Padel and gym).

Author

Alessandro Paoli

My name is Alessandro Paoli and I've been a Technical Consultant at Wurth Phoenix since May 2024. I've always had a great passion for IT and since 2004 it has also become my job. In 2015 I found my role in the field, monitoring. I have had the opportunity to use various monitoring products, both open source and proprietary, I have worked on numerous projects from small businesses to global companies. I am married and have 2 wonderful daughters. My passions are travel, cinema, games (video and board) and comics, and every now and then I manage to indulge in a few days of sport (Padel and gym).

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive