diff --git a/certificates.js b/certificates.js index 93afe34..89f8d76 100644 --- a/certificates.js +++ b/certificates.js @@ -19,8 +19,7 @@ var mkdirpAsync = PromiseA.promisify(require('@root/mkdirp')); certificates.check = function(opts) { // { certificate.id, subject, ... } var id = (opts.certificate && opts.certificate.id) || opts.subject; - //console.log('certificates.check for', opts.certificate, opts.subject); - //console.log(opts); + //console.log('certificates.check for', opts); // For advanced use cases: // This just goes to show that any options set in approveDomains() will be available here @@ -73,7 +72,7 @@ certificates.check = function(opts) { // Use certificate.kid, certificate.id, or subject to find a certificate keypair // Return an object with string privateKeyPem and/or object privateKeyJwk (or null, not undefined) certificates.checkKeypair = function(opts) { - //console.log('certificates.checkKeypair:', opts.certificate, opts.subject); + //console.log('certificates.checkKeypair:', opts); return readFileAsync( U._tameWild(privkeyPath(store, opts), opts.subject), @@ -124,7 +123,7 @@ certificates.setKeypair = function(opts) { // Use certificate.id (or subject if no ki is present) to save a certificate // Return null (not undefined) on success, or throw on error certificates.set = function(opts) { - //console.log('certificates.set:', opts.subject, opts.pems); + //console.log('certificates.set:', opts); var pems = { cert: opts.pems.cert, // string PEM the first half of the concatonated fullchain.pem cert chain: opts.pems.chain, // string PEM the second half (yes, you need this too) @@ -223,13 +222,12 @@ function privkeyPath(store, opts) { } function certPath(store, opts) { - var dir = U._tpl( - store, - opts, + var pathname = opts.certPath || - store.options.certPath || - path.join(liveDir(), 'cert.pem') - ); + store.options.certPath || + path.join(liveDir(), 'cert.pem'); + + var dir = U._tpl(store, opts, pathname); return U._tameWild(dir, opts.subject || ''); } diff --git a/utils.js b/utils.js index f334c45..6286a98 100644 --- a/utils.js +++ b/utils.js @@ -22,7 +22,11 @@ U._tpl = function tpl(store, opts, str) { ].forEach(function(group) { group.forEach(function(tmpl) { group.forEach(function(key) { - var item = store.options[key] || opts[key] || ''; + var item = opts[key] || store.options[key]; + if ('string' !== typeof item) { + return; + } + if ('directoryUrl' === key) { item = item.replace(/^https?:\/\//i, ''); } @@ -35,6 +39,7 @@ U._tpl = function tpl(store, opts, str) { // item = item; } } + if (-1 === str.indexOf(':' + tmpl)) { return; }