Configuring LDAP with Elasticsearch 6.2.3

Hi there,

I am trying to build infrastructure for elastic. I was able to setup elastic and kibana with x-pack. I am facing issue while configuring ldap, and here is what I have done till now.

Step 1-
used open_ssl to download ldap cert and added it to java cacerts ( elastic is using, in this case its openjdk and path is /bin/java and version is openjdk version "1.8.0_161".

Step 2 - Ran this command to create CA cert.
elasticsearch-6.2.3/bin/x-pack/certgen --dn 'CN=rnd elastic server' --pass --days 3650 --keysize 4096 --out elk_ca/

Step 3 - Unzip this file and placed them in elastic config/certs dir.

Step 4 - configure elasticsearch.yml as follows.

xpack.ssl.key: certs/rnd.key
xpack.ssl.certificate: certs/rnd.crt
xpack.ssl.certificate_authorities: certs/ca.crt true true true
xpack.ssl.verification_mode: certificate

#------------------------------------X PACK LDAP-------------------------------
          type: ldap
          order: 0
          url: "ldaps://"
          bind_dn: "cn=abc,ou=xyz,ou=xy,o=abc"
          bind_password: xxxxx
            base_dn: "ou=Employees,ou=People,o=abc"
            attribute: cn
            base_dn: "ou=Groups,o=abc"
            role_mapping: "/opt/app/elasticsearch-6.2.3/config/x-pack/role_mapping.yml"
          unmapped_groups_as_roles: false

Step 5 -
Added my id as superuser in role_mapping.yml file

  • "cn=myid,ou=Employees,ou=People,o=abc"

restarted the elastic server.

Now when I am trying to access https://myhostname:9200, it pops up for userid/password and after submitting with credentials, it gives me the following error.

2018-06-29T00:20:37,050][WARN ][o.e.x.s.a.AuthenticationService] [rnd] Authentication to realm ldap1 failed - authenticate failed (Caused by LDAPException(resultCode=91 (connect error), errorMessage='An error occurred while attempting to connect to server LDAPException(resultCode=91 (connect error), errorMessage='Unable to verify an attempt to to establish a secure connection to '' because an unexpected error was encountered during validation processing: SSLPeerUnverifiedException(message='peer not authenticated', trace='getPeerCertificates( / verifySSLSocket( / ( / connect( / connect( / connect( / ( / getConnection( / getConnection( / getConnection( / createConnection( / createConnection( / getConnection( / doPrivileged( / privilegedConnect( / searchForEntry( / searchForEntry( / findUser( / getSessionWithPool( / session( / lambda$doAuthenticate$1( / doRun( / doRun( / run( / runWorker( / run( / run(', revision=24201)')'))

What am I missing here?
Do I need to create separate keystore to add ldap cert in it or where to add ldap cert?

Any help would be appreciated!


1 Like

Hi @Devesh_Pandey,

Please look at the documentation for more information:
Hope this helps.

Yogesh Gaikwad

When you configure xpack.ssl.certificate_authorities that takes precedence over the CA certs that exist in your JVM, so the ldap cert you added to your java cacerts isn't used.

Yogesh's link shows how to configure a certificate authority specifically for the LDAP connection.

@TimV thanks a lot it worked.

@Yogesh_Gaikwad Thanks a lot , it worked.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.