*Refactor loading of ssl
This commit is contained in:
parent
d5a4956be7
commit
c26be980c5
|
@ -62,11 +62,21 @@ export class SSLManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _maybeUpdateContext() {
|
private _maybeUpdateContext() {
|
||||||
if (b4a.isBuffer(this._cert) && b4a.isBuffer(this._key)) {
|
const valid = (value: any) =>
|
||||||
this._context = tls.createSecureContext({
|
b4a.isBuffer(value) || typeof value === "string" || Array.isArray(value);
|
||||||
cert: this._cert,
|
|
||||||
|
if (valid(this._cert) && valid(this._key)) {
|
||||||
|
const opts: tls.SecureContextOptions = {
|
||||||
key: this._key,
|
key: this._key,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (Array.isArray(this._cert)) {
|
||||||
|
opts.ca = this._cert.slice(1);
|
||||||
|
opts.cert = this._cert[0];
|
||||||
|
} else {
|
||||||
|
opts.cert = this._cert;
|
||||||
|
}
|
||||||
|
this._context = tls.createSecureContext(opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue