Reading certs is now async.
This commit is contained in:
parent
ae20ca5558
commit
faf5ff6aa4
@ -27,6 +27,7 @@
|
|||||||
"babel-runtime": "^6.3.19",
|
"babel-runtime": "^6.3.19",
|
||||||
"bluebird": "^3.1.1",
|
"bluebird": "^3.1.1",
|
||||||
"event-to-promise": "^0.6.0",
|
"event-to-promise": "^0.6.0",
|
||||||
|
"fs-promise": "^0.3.1",
|
||||||
"ldapjs": "^1.0.0"
|
"ldapjs": "^1.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/* eslint no-throw-literal: 0 */
|
/* eslint no-throw-literal: 0 */
|
||||||
|
|
||||||
import {promisify} from 'bluebird'
|
|
||||||
import eventToPromise from 'event-to-promise'
|
import eventToPromise from 'event-to-promise'
|
||||||
import {createClient} from 'ldapjs'
|
import { createClient } from 'ldapjs'
|
||||||
import {escape} from 'ldapjs/lib/filters/escape'
|
import { escape } from 'ldapjs/lib/filters/escape'
|
||||||
import {readFileSync} from 'fs'
|
import { promisify } from 'bluebird'
|
||||||
|
import { readFile } from 'fs-promise'
|
||||||
|
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class AuthLdap {
|
|||||||
this._authenticate = bind(this._authenticate, this)
|
this._authenticate = bind(this._authenticate, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
configure (conf) {
|
async configure (conf) {
|
||||||
const clientOpts = this._clientOpts = {
|
const clientOpts = this._clientOpts = {
|
||||||
url: conf.uri,
|
url: conf.uri,
|
||||||
maxConnections: 5,
|
maxConnections: 5,
|
||||||
@ -123,8 +123,9 @@ class AuthLdap {
|
|||||||
|
|
||||||
tlsOptions.rejectUnauthorized = checkCertificate
|
tlsOptions.rejectUnauthorized = checkCertificate
|
||||||
if (certificateAuthorities) {
|
if (certificateAuthorities) {
|
||||||
// FIXME: should be async!!!
|
tlsOptions.ca = await Promise.all(
|
||||||
tlsOptions.ca = certificateAuthorities.map(path => readFileSync(path))
|
certificateAuthorities.map(path => readFile(path))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user