From b54abc2c5b38e242615cc8538777278f61700ba1 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 16 Aug 2016 13:03:15 -0600 Subject: [PATCH] #21 workaround unconfigured le-sni-auto plugin --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index e990636..f004b3e 100644 --- a/index.js +++ b/index.js @@ -172,10 +172,11 @@ LE.create = function (le) { if (!le.httpsOptions.SNICallback) { if (!le.getCertificatesAsync && !le.getCertificates) { if (!le.approveDomains) { - if (!(le.approvedDomains && le.email && le.agreeTos)) { - throw new Error("You must provide opts.approveDomains(domain, certs, callback) to approve certificates"); - } + le.approvedDomains = le.approvedDomains || []; le.approveDomains = function (lexOpts, certs, cb) { + if (!(le.approvedDomains.length && le.email && le.agreeTos)) { + throw new Error("le-sni-auto is not properly configured. Missing one or more of approveDomains(domain, certs, callback) or approvedDomains (array), email, or agreeTos"); + } if (lexOpts.domains.every(function (domain) { return -1 !== le.approvedDomains.indexOf(domain); })) {