From 2e747bada2a9e1d16bc702456dda297e1cd191a3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 5 Apr 2018 03:37:41 -0600 Subject: [PATCH] sequence auths, more testing --- README.md | 2 ++ node.js | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb1d3da..ee602bf 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ In progress * Mar 21, 2018 - *mostly* matches le-acme-core.js API * Apr 5, 2018 - completely match api for acme v1 (le-acme-core.js) * Apr 5, 2018 - test wildcard +* Apr 5, 2018 - test two subdomains +* Apr 5, 2018 - test subdomains and its wildcard Todo diff --git a/node.js b/node.js index f87a88f..50cae2f 100644 --- a/node.js +++ b/node.js @@ -218,15 +218,27 @@ ACME._postChallenge = function (me, options, identifier, ch) { if (1 === options.removeChallenge.length) { options.removeChallenge( { identifier: identifier + , hostname: identifier.value , type: ch.type , token: ch.token + , thumbprint: thumbprint + , keyAuthorization: keyAuthorization + , dnsAuthorization: me.RSA.utils.toWebsafeBase64( + require('crypto').createHash('sha256').update(keyAuthorization).digest('base64') + ) } ).then(function () {}, function () {}); } else if (2 === options.removeChallenge.length) { options.removeChallenge( { identifier: identifier + , hostname: identifier.value , type: ch.type , token: ch.token + , thumbprint: thumbprint + , keyAuthorization: keyAuthorization + , dnsAuthorization: me.RSA.utils.toWebsafeBase64( + require('crypto').createHash('sha256').update(keyAuthorization).digest('base64') + ) } , function (err) { return err; } ); @@ -403,6 +415,7 @@ ACME._getCertificate = function (me, options) { }).then(function (resp) { me._nonce = resp.toJSON().headers['replay-nonce']; var location = resp.toJSON().headers.location; + var auths; if (me.debug) { console.log(location); // the account id url console.log(resp.toJSON()); @@ -418,8 +431,12 @@ ACME._getCertificate = function (me, options) { if (me.debug) { console.log("47 &#&#&#&#&#&#&&##&#&#&#&#&#&#&#&"); } //return resp.body; - return Promise.all(me._authorizations.map(function (authUrl, i) { - if (me.debug) { console.log("Authorizations map #" + i); } + auths = me._authorizations.slice(0); + + function next() { + var authUrl = auths.shift(); + if (!authUrl) { return; } + return ACME._getChallenges(me, options, authUrl).then(function (results) { // var domain = options.domains[i]; // results.identifier.value var chType = options.challengeTypes.filter(function (chType) { @@ -439,8 +456,12 @@ ACME._getCertificate = function (me, options) { } return ACME._postChallenge(me, options, results.identifier, challenge); + }).then(function () { + return next(); }); - })).then(function () { + } + + return next().then(function () { if (me.debug) { console.log("37 &#&#&#&#&#&#&&##&#&#&#&#&#&#&#&"); } var validatedDomains = body.identifiers.map(function (ident) { return ident.value;