Merge branch 'master' of jshaver/acme-v2.js into master

This commit is contained in:
jshaver 2018-06-06 19:27:39 +00:00 committed by Gitea
commit b3e1409394
1 changed files with 16 additions and 9 deletions

25
node.js
View File

@ -384,15 +384,10 @@ ACME._postChallenge = function (me, options, identifier, ch) {
me._nonce = resp.toJSON().headers['replay-nonce'];
if (me.debug) console.debug('respond to challenge: resp.body:');
if (me.debug) console.debug(resp.body);
return ACME._wait(1 * 1000).then(pollStatus).then(resolve, reject);
return ACME._wait(1 * 1000).then(pollStatus);
});
}
function failChallenge(err) {
if (err) { reject(err); return; }
return testChallenge();
}
function testChallenge() {
// TODO put check dns / http checks here?
// http-01: GET https://example.org/.well-known/acme-challenge/{{token}} => {{keyAuth}}
@ -410,11 +405,23 @@ ACME._postChallenge = function (me, options, identifier, ch) {
try {
if (1 === options.setChallenge.length) {
options.setChallenge(auth).then(testChallenge, reject);
options.setChallenge(auth).then(testChallenge).then(resolve, reject);
} else if (2 === options.setChallenge.length) {
options.setChallenge(auth, failChallenge);
options.setChallenge(auth, function(err) {
if(err) {
reject(err);
} else {
options.setChallenge(identifier.value, ch.token, keyAuthorization, failChallenge);
testChallenge().then(resolve, reject);
}
});
} else {
options.setChallenge(identifier.value, ch.token, keyAuthorization, function(err) {
if(err) {
reject(err);
} else {
testChallenge().then(resolve, reject);
}
});
}
} catch(e) {
reject(e);