diff --git a/manager.js b/manager.js index 01dcc5b..d749872 100644 --- a/manager.js +++ b/manager.js @@ -180,30 +180,42 @@ Manage.create = function(opts) { //args.issuedBefore = Date.now() - 30 * 24 * 60 * 60 * 1000; // i.e. find certs more that will expire in less than 45 days //args.expiresBefore = Date.now() + 45 * 24 * 60 * 60 * 1000; - var issuedBefore = args.issuedBefore || 0; + var issuedBefore = args.issuedBefore || Infinity; var expiresBefore = args.expiresBefore || Infinity; //Date.now() + 21 * 24 * 60 * 60 * 1000; var altnames = (args.altnames || args.domains || []).slice(0); if (args.servername && !altnames.includes(args.servername)) { altnames.push(args.servername); } - if (args.subject && !altnames.includes(args.subject)) { - altnames.push(args.subject); + if (args.wildname && !altnames.includes(args.wildname)) { + altnames.push(args.wildname); } // TODO match ANY domain on any cert var sites = Object.keys(config.sites || {}) .filter(function(sub) { var site = config.sites[sub]; - if ( - !site.deletedAt || - site.expiresAt < expiresBefore || - site.issuedAt < issuedBefore - ) { - return (site.altnames || []).some(function(name) { - return altnames.includes(name); - }); + if (site.deletedAt) { + return false; } + if (site.expiresAt >= expiresBefore) { + return false; + } + if (site.issuedAt >= issuedBefore) { + return false; + } + + // if subject is specified, don't return anything else + if (args.subject) { + if (site.subject === args.subject) { + return true; + } + } + + // altnames, servername, and wildname all get rolled into one + return (site.altnames || []).some(function(name) { + return altnames.includes(name); + }); }) .map(function(name) { var site = config.sites[name]; diff --git a/package-lock.json b/package-lock.json index d8b95fe..df5b77c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "greenlock-manager-fs", - "version": "0.6.2", + "version": "0.6.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a6f64e8..7e2a1bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "greenlock-manager-fs", - "version": "0.6.2", + "version": "0.6.3", "description": "A simple file-based management strategy for Greenlock", "main": "manager.js", "scripts": {