I'm using passport with Express in NodeJS to use LDAP authentication for my application and I am getting an error:
events.js:154
throw er; // Unhandled 'error' event
^
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1065:38)
at emitNone (events.js:80:13)
at TLSSocket.emit (events.js:179:7)
at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:593:8)
at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:425:38)
I have all the ldap options in a config file and then I add the ca stuff like so:
opts.tlsOptions.ca = [fs.readFileSync('./config/ldap.pem')];
passport.use(new LdapStrategy({server: opts}));
I googled the error and found the following answer on here: Error: unable to verify the first certificate in nodejs so I added the following before I initialize my ldap stuff:
require('ssl-root-cas').addFile('./config/ldap.pem');
However this solution didn't work for me at all. I am at my wits end. I really hope someone can see what I'm doing wrong.