diff --git a/lib/config/index.js b/lib/config/index.js index 81f407ab9..f5334749d 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -1,3 +1,5 @@ +const fs = require('fs'); +const path = require('path'); const config = require('snyk-config')(__dirname + '/..'); const { camelify } = require('./utils'); @@ -14,5 +16,5 @@ dotenv.config({ dotenvExpand(process.env); const res = Object.assign({}, camelify(config), camelify(process.env)); - +res.caCert = (() => {return res.caCert ? fs.readFileSync(path.resolve(process.cwd(), res.caCert)) : undefined;})(), module.exports = res; diff --git a/lib/relay.js b/lib/relay.js index 6a30e047f..0f8464876 100644 --- a/lib/relay.js +++ b/lib/relay.js @@ -1,5 +1,3 @@ -const fs = require('fs'); -const path = require('path'); const request = require('request'); const undefsafe = require('undefsafe'); const parse = require('url').parse; @@ -115,7 +113,7 @@ function responseHandler(filterRules, config) { method, body, agentOptions: { - ca: (() => {return config.caCert ? fs.readFileSync(path.resolve(process.cwd(), config.caCert)) : undefined;})(), + ca: config.caCert, // Optional CA cert }, }, (error, response, body) => { debug('%s %s (%s)', method, result, (response || { statusCode: 500 }).statusCode);