diff --git a/lib/get-certificate.js b/lib/get-certificate.js index b6b0540..53a11fc 100644 --- a/lib/get-certificate.js +++ b/lib/get-certificate.js @@ -166,7 +166,18 @@ module.exports.create = function (deps) { options.setChallenge(state.domain, challenge.token, keyAuthorization, challengeDone); - function challengeDone() { + function challengeDone(err) { + if (err) { + console.error('[letiny-core] setChallenge Error:'); + console.error(err && err.stack || err); + ensureValidation(err, null, null, function () { + options.removeChallenge(state.domain, challenge.token, function () { + // ignore + }); + }); + return; + } + state.acme.post(state.responseUrl, { resource:'challenge', keyAuthorization:keyAuthorization @@ -193,7 +204,8 @@ module.exports.create = function (deps) { if (err || Math.floor(res.statusCode/100)!==2) { unlink(); - return handleErr(err, 'Authorization status request failed ('+res.statusCode+')'); + return handleErr(err, 'Authorization status request failed (' + + (res && res.statusCode || err.code || err.message || err) + ')'); } authz=body;