From cbc33c357883bbd93b42e29993d49b57762f8b4a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 25 Apr 2014 16:34:53 -0600 Subject: [PATCH] addFile() allows leading '/' in path --- ca-store-generator.js | 3 ++- package.json | 2 +- ssl-root-cas.js | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ca-store-generator.js b/ca-store-generator.js index 457a258..4cd701a 100644 --- a/ca-store-generator.js +++ b/ca-store-generator.js @@ -137,8 +137,9 @@ function dumpCerts(certs) { + "};\n" + "module.exports.addFile = function (filepath) {\n" + " var opts = require('https').globalAgent.options;\n" + + " var root = filepath[0] === '/' ? '/' : '';\n" + " opts.ca = opts.ca || [];\n" - + " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, filepath.split(/\\//g))));\n" + + " opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\\//g))));\n" + " return module.exports;\n" + "};\n" ); diff --git a/package.json b/package.json index c400044..a0381f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssl-root-cas", - "version": "1.1.0", + "version": "1.1.1", "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 4372749..c636881 100644 --- a/ssl-root-cas.js +++ b/ssl-root-cas.js @@ -4094,8 +4094,17 @@ var cas = module.exports = [ "3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed\n" + "-----END CERTIFICATE-----\n" ]; +module.exports.rootCas = cas; module.exports.inject = function () { var opts = require('https').globalAgent.options; if (!opts.ca || !opts.ca.__injected) { opts.ca = (opts.ca||[]).concat(cas); } opts.ca.__injected = true; + return module.exports; +}; +module.exports.addFile = function (filepath) { + var opts = require('https').globalAgent.options; + var root = filepath[0] === '/' ? '/' : ''; + opts.ca = opts.ca || []; + opts.ca.push(require('fs').readFileSync(require('path').join.apply(null, (root + filepath).split(/\//g)))); + return module.exports; };