Skip to content

Commit

Permalink
refactor: cache CA cert file in config
Browse files Browse the repository at this point in the history
  • Loading branch information
JackuB authored and gjvis committed Oct 11, 2016
1 parent 97469ee commit 0a801b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/config/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const config = require('snyk-config')(__dirname + '/..');

const { camelify } = require('./utils');
Expand All @@ -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;
4 changes: 1 addition & 3 deletions lib/relay.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0a801b1

Please sign in to comment.