bugfix updates for Greenlock v3

This commit is contained in:
AJ ONeal 2019-10-27 04:32:24 -06:00
parent 6d398d36c4
commit ba284d0004
2 changed files with 14 additions and 11 deletions

View File

@ -19,8 +19,7 @@ var mkdirpAsync = PromiseA.promisify(require('@root/mkdirp'));
certificates.check = function(opts) { certificates.check = function(opts) {
// { certificate.id, subject, ... } // { certificate.id, subject, ... }
var id = (opts.certificate && opts.certificate.id) || opts.subject; var id = (opts.certificate && opts.certificate.id) || opts.subject;
//console.log('certificates.check for', opts.certificate, opts.subject); //console.log('certificates.check for', opts);
//console.log(opts);
// For advanced use cases: // For advanced use cases:
// This just goes to show that any options set in approveDomains() will be available here // 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 // 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) // Return an object with string privateKeyPem and/or object privateKeyJwk (or null, not undefined)
certificates.checkKeypair = function(opts) { certificates.checkKeypair = function(opts) {
//console.log('certificates.checkKeypair:', opts.certificate, opts.subject); //console.log('certificates.checkKeypair:', opts);
return readFileAsync( return readFileAsync(
U._tameWild(privkeyPath(store, opts), opts.subject), 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 // Use certificate.id (or subject if no ki is present) to save a certificate
// Return null (not undefined) on success, or throw on error // Return null (not undefined) on success, or throw on error
certificates.set = function(opts) { certificates.set = function(opts) {
//console.log('certificates.set:', opts.subject, opts.pems); //console.log('certificates.set:', opts);
var pems = { var pems = {
cert: opts.pems.cert, // string PEM the first half of the concatonated fullchain.pem cert 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) 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) { function certPath(store, opts) {
var dir = U._tpl( var pathname =
store,
opts,
opts.certPath || opts.certPath ||
store.options.certPath || store.options.certPath ||
path.join(liveDir(), 'cert.pem') path.join(liveDir(), 'cert.pem');
);
var dir = U._tpl(store, opts, pathname);
return U._tameWild(dir, opts.subject || ''); return U._tameWild(dir, opts.subject || '');
} }

View File

@ -22,7 +22,11 @@ U._tpl = function tpl(store, opts, str) {
].forEach(function(group) { ].forEach(function(group) {
group.forEach(function(tmpl) { group.forEach(function(tmpl) {
group.forEach(function(key) { 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) { if ('directoryUrl' === key) {
item = item.replace(/^https?:\/\//i, ''); item = item.replace(/^https?:\/\//i, '');
} }
@ -35,6 +39,7 @@ U._tpl = function tpl(store, opts, str) {
// item = item; // item = item;
} }
} }
if (-1 === str.indexOf(':' + tmpl)) { if (-1 === str.indexOf(':' + tmpl)) {
return; return;
} }