Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
if (err) {
return callback(err, result);
}
var tlsOptions;
if (config.LDAP_URL.toLowerCase().substr(0, 5) === 'ldaps') {
var cas;
if (process.platform === 'win32') {
const ca = require('win-ca');
cas = [];
ca({
format: ca.der2.pem,
store: ['root', 'ca', 'trustedpeople'],
ondata: cas
});
} else {
cas = https.globalAgent.options.ca;
}
tlsOptions = {
ca: cas
};
if (nconf.get('SSL_ENABLE_EMPTY_SUBJECT')) {
// When enabled use the connector own verification function that fixes Node.js issue described in https://github.com/nodejs/node/issues/11771 for details
tlsOptions.checkServerIdentity = tls.checkServerIdentity;
}
}
function readSystemCAs(cb) {
switch(process.platform) {
case 'win32':
console.log('Reading CA certificates from Windows Store');
const ca = require('win-ca');
const list = [];
ca({
format: ca.der2.pem,
store: ['root', 'ca', 'trustedpeople'],
ondata: list
});
cb(null, list.map(c => ({ pem: c })));
break;
case 'freebsd':
case 'linux':
console.log('Reading CA certificates from OPENSSLDIR');
exec('openssl version -d', function(err, stdout, stderr){
if (err) return cb(err);
var match = SSL_OPENSSLDIR_PATTERN.exec(stdout);
if (match && match.length > 1) {
return readCertficatesFromPath(path.join(match[1], 'certs'), cb);
}