From 6d346552763bc32f9c978e0915f3202f84b3f384 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 4 Feb 2019 23:04:24 -0700 Subject: [PATCH] #11 skip challenge when valid --- node.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/node.js b/node.js index 1bc21ee..244abf8 100644 --- a/node.js +++ b/node.js @@ -637,6 +637,13 @@ ACME._getCertificate = function (me, options) { return results.challenges.some(function (ch) { return ch.type === chType; }); + }).sort(function (aType, bType) { + var a = results.challenges.filter(function (ch) { return ch.type === aType; })[0]; + var b = results.challenges.filter(function (ch) { return ch.type === bType; })[0]; + + if ('valid' === a.status) { return 1; } + if ('valid' === b.status) { return -1; } + return 0; })[0]; var challenge = results.challenges.filter(function (ch) { @@ -651,6 +658,10 @@ ACME._getCertificate = function (me, options) { )); } + if ("valid" === challenge.status) { + return; + } + return ACME._postChallenge(me, options, results.identifier, challenge); }).then(function () { return next();