tlsopt.js
function read() {
    const TLS_CERT = process.env.TLS_CERT;
    const TLS_KEY = process.env.TLS_KEY;
    const TLS_CA = process.env.TLS_CA;
    const tls_cert = readOpt("--tls-cert");
    const tls_key = readOpt("--tls-key");
    const tls_ca = readOpt("--tls-ca");
    const result = {};

    if (tls_cert) {
        if (tls_key) {
            result.cert = readFile(tls_cert);
            result.key = readFile(tls_key);

            if (tls_ca) {
                result.ca = readFile(tls_ca);
            }
        } else {
            result.pfx = readFile(tls_cert);
        }
    } else if (TLS_CERT) {
        if (TLS_KEY) {
            result.cert = readFile(TLS_CERT);
            result.key = readFile(TLS_KEY);

            if (TLS_CA) {
                result.ca = readFile(TLS_CA);
            }
        } else {
            result.pfx = readFile(TLS_CERT);
        }
    }

    return Promise.all(keys(result).map(key => result[key].then(data => {
        return result[key] = data;
    }))).then(() => result);
}
function read() {
    const TLS_CERT = process.env.TLS_CERT;
    const TLS_KEY = process.env.TLS_KEY;
    const TLS_CA = process.env.TLS_CA;
    const tls_cert = readOpt("--tls-cert");
    const tls_key = readOpt("--tls-key");
    const tls_ca = readOpt("--tls-ca");
    const result = {};

    if (tls_cert) {
        if (tls_key) {
            result.cert = readFile(tls_cert);
            result.key = readFile(tls_key);

            if (tls_ca) {
                result.ca = readFile(tls_ca);
            }
        } else {
            result.pfx = readFile(tls_cert);
        }
    } else if (TLS_CERT) {
        if (TLS_KEY) {
            result.cert = readFile(TLS_CERT);
            result.key = readFile(TLS_KEY);

            if (TLS_CA) {
                result.ca = readFile(TLS_CA);
            }
        } else {
            result.pfx = readFile(TLS_CERT);
        }
    }

    return Promise.all(keys(result).map(key => result[key].then(data => {
        return result[key] = data;
    }))).then(() => result);
}
Read TLS options from filesystem asynchronously.  Paths are read from CLI
options or environment variables.
@returns {Promise}