diff --git a/lib/sni-callback.js b/lib/sni-callback.js index 8396006..fcfb3c4 100644 --- a/lib/sni-callback.js +++ b/lib/sni-callback.js @@ -126,6 +126,11 @@ module.exports.create = function (opts) { if (opts.debug) { console.debug("[LEX] '" + hostname + "' is not registered, requesting approval"); } + + if (!hostname) { + sniCb(new Error('[registerCert] no hostname')); + return; + } opts.approveRegistration(hostname, function (err, args) { @@ -157,6 +162,11 @@ module.exports.create = function (opts) { } function fetch(hostname, sniCb) { + if (!hostname) { + sniCb(new Error('[sniCallback] [fetch] no hostname')); + return; + } + opts.letsencrypt.fetch({ domains: [hostname] }, function (err, certInfo) { if (opts.debug) { console.debug("[LEX] fetch from disk result '" + hostname + "':"); @@ -184,7 +194,10 @@ module.exports.create = function (opts) { var now = Date.now(); var certInfo = ipc[hostname]; - + if (!hostname) { + cb(new Error('[sniCallback] no hostname')); + return; + } // // No cert is available in cache.