Unverified Commit b1060180 authored by Kevyn Bruyere's avatar Kevyn Bruyere Committed by GitHub

fix: LDAP - avoid reading empty tls cert file (#2980)

parent cfbd3dca
......@@ -18,12 +18,7 @@ module.exports = {
bindCredentials: conf.bindCredentials,
searchBase: conf.searchBase,
searchFilter: conf.searchFilter,
tlsOptions: (conf.tlsEnabled) ? {
rejectUnauthorized: conf.verifyTLSCertificate,
ca: [
fs.readFileSync(conf.tlsCertPath)
]
} : {},
tlsOptions: getTlsOptions(conf),
includeRaw: true
},
usernameField: 'email',
......@@ -56,3 +51,25 @@ module.exports = {
))
}
}
function getTlsOptions(conf) {
if (!conf.tlsEnabled) {
return {}
}
if (!conf.tlsCertPath) {
return {
rejectUnauthorized: conf.verifyTLSCertificate,
}
}
const caList = []
if (conf.verifyTLSCertificate) {
caList.push(fs.readFileSync(conf.tlsCertPath))
}
return {
rejectUnauthorized: conf.verifyTLSCertificate,
ca: caList
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment