vesse / passport-ldapauth

LDAP authentication strategy for Passport
MIT License
312 stars 100 forks source link

SSL with docker openldap #69

Closed zhenwan closed 6 years ago

zhenwan commented 6 years ago

Has anyone tried Openldap docker image with self-signed certificate? I use "Active Directory over SSL example" as sample code for Openldap, but always get following error. Hope someone knows why I get this error:

Error: socket hang up at TLSSocket.onHangUp (_tls_wrap.js:1116:19) at Object.onceWrapper (events.js:293:19) at emitNone (events.js:91:20) at TLSSocket.emit (events.js:188:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)

vesse commented 6 years ago

You might have better luck in stackoverflow. This as such is not an issue in the library - it might be if using ldapjs directly works but connecting via this library does not.

dangtony98 commented 8 months ago

For any future readers, if it helps, I was able to get passport-ldapauth to work with an OpenLDAP server with a self-signed certificate with the following configuration on the end of passport-ldapauth:

server: {
    url: 'ldaps://openldap:636',
    bindDN: '...',
    bindCredentials: '...',
    searchBase: '...,
    searchFilter: '(uid={{username}})',
    tlsOptions: {
        ca: [caCert]
    }
}

Using osixia/openldap:1.5.0 docker image, the following configuration was relevant:

Environment variables:

LDAP_TLS_CRT_FILENAME: ldapserver.crt
LDAP_TLS_KEY_FILENAME: ldapserver.key
LDAP_TLS_CA_CRT_FILENAME: ldapserver.crt
LDAP_TLS_VERIFY_CLIENT: try

Volumes:

./path-to-certs:/container/service/slapd/assets/certs