From 125d31b2c419d0d554a574f93155f2a2267f33a5 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 4 Jul 2018 00:36:33 -0600 Subject: [PATCH] * the other callback --- .gitignore | 1 + node.js | 20 ++++++++++---------- tests/compat.js | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index bf23d29..052547a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.pem letsencrypt.work letsencrypt.logs letsencrypt.config diff --git a/node.js b/node.js index ddb2866..34c5b5c 100644 --- a/node.js +++ b/node.js @@ -416,7 +416,15 @@ ACME._postChallenge = function (me, options, identifier, ch) { if (1 === options.setChallenge.length) { options.setChallenge(auth).then(testChallenge).then(resolve, reject); } else if (2 === options.setChallenge.length) { - var challengeCb = function (err) { + options.setChallenge(auth, function (err) { + if(err) { + reject(err); + } else { + testChallenge().then(resolve, reject); + } + }); + } else { + var challengeCb = function(err) { if(err) { reject(err); } else { @@ -426,15 +434,7 @@ ACME._postChallenge = function (me, options, identifier, ch) { Object.keys(auth).forEach(function (key) { challengeCb[key] = auth[key]; }); - options.setChallenge(auth, challengeCb); - } else { - options.setChallenge(identifier.value, ch.token, keyAuthorization, function(err) { - if(err) { - reject(err); - } else { - testChallenge().then(resolve, reject); - } - }); + options.setChallenge(identifier.value, ch.token, keyAuthorization, challengeCb); } } catch(e) { reject(e); diff --git a/tests/compat.js b/tests/compat.js index b48cfef..e643e2e 100644 --- a/tests/compat.js +++ b/tests/compat.js @@ -26,7 +26,7 @@ module.exports.run = function (directoryUrl, RSA, web, chType, email, accountKey console.log("dig TXT " + pathname + " '" + cb.dnsAuthorization + "'"); console.log("\nThen hit the 'any' key to continue..."); } else { - cb(new Error("[acme-v2] unrecognized challenge type")); + cb(new Error("[acme-v2] unrecognized challenge type: " + cb.type)); return; }