diff --git a/ca-store-generator.js b/ca-store-generator.js index 4cd701a..26a09ea 100644 --- a/ca-store-generator.js +++ b/ca-store-generator.js @@ -138,8 +138,10 @@ function dumpCerts(certs) { + "module.exports.addFile = function (filepath) {\n" + " var opts = require('https').globalAgent.options;\n" + " var root = filepath[0] === '/' ? '/' : '';\n" + + " var filepaths = filepath.split(/\\//g);\n" + + " if (root) { filepaths.unshift(root); }\n" + " opts.ca = opts.ca || [];\n" - + " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\\//g))));\n" + + " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, filepaths)));\n" + " return module.exports;\n" + "};\n" ); diff --git a/package.json b/package.json index a0381f0..04986d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssl-root-cas", - "version": "1.1.1", + "version": "1.1.2", "description": "The module you need to solve node's SSL woes when including a custom certificate.", "main": "ssl-root-cas", "scripts": { diff --git a/ssl-root-cas.js b/ssl-root-cas.js index c636881..8248a72 100644 --- a/ssl-root-cas.js +++ b/ssl-root-cas.js @@ -4104,7 +4104,9 @@ module.exports.inject = function () { module.exports.addFile = function (filepath) { var opts = require('https').globalAgent.options; var root = filepath[0] === '/' ? '/' : ''; + var filepaths = filepath.split(/\//g); + if (root) { filepaths.unshift(root); } opts.ca = opts.ca || []; - opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\//g)))); + opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, filepaths))); return module.exports; };