From e0202a559eeae2dc9df4e13deaf5cb28f96b51ff Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 11 Feb 2016 15:22:41 -0500 Subject: [PATCH] handle setChallenge failure --- lib/get-certificate.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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;