update compat to allow testing dns

This commit is contained in:
AJ ONeal 2018-07-04 00:28:00 -06:00
parent a67256e8a9
commit 63284386eb
4 changed files with 25 additions and 8 deletions

View File

@ -416,13 +416,17 @@ ACME._postChallenge = function (me, options, identifier, ch) {
if (1 === options.setChallenge.length) { if (1 === options.setChallenge.length) {
options.setChallenge(auth).then(testChallenge).then(resolve, reject); options.setChallenge(auth).then(testChallenge).then(resolve, reject);
} else if (2 === options.setChallenge.length) { } else if (2 === options.setChallenge.length) {
options.setChallenge(auth, function(err) { var challengeCb = function (err) {
if(err) { if(err) {
reject(err); reject(err);
} else { } else {
testChallenge().then(resolve, reject); testChallenge().then(resolve, reject);
} }
};
Object.keys(auth).forEach(function (key) {
challengeCb[key] = auth[key];
}); });
options.setChallenge(auth, challengeCb);
} else { } else {
options.setChallenge(identifier.value, ch.token, keyAuthorization, function(err) { options.setChallenge(identifier.value, ch.token, keyAuthorization, function(err) {
if(err) { if(err) {

View File

@ -1,6 +1,6 @@
{ {
"name": "acme-v2", "name": "acme-v2",
"version": "1.1.0", "version": "1.1.1",
"description": "Free SSL. A framework for building Let's Encrypt v2 clients, and other ACME v2 (draft 11) clients. Successor to le-acme-core.js", "description": "Free SSL. A framework for building Let's Encrypt v2 clients, and other ACME v2 (draft 11) clients. Successor to le-acme-core.js",
"homepage": "https://git.coolaj86.com/coolaj86/acme-v2.js", "homepage": "https://git.coolaj86.com/coolaj86/acme-v2.js",
"main": "node.js", "main": "node.js",

View File

@ -12,10 +12,23 @@ module.exports.run = function (directoryUrl, RSA, web, chType, email, accountKey
agree(null, tosUrl); agree(null, tosUrl);
} }
, setChallenge: function (hostname, token, val, cb) { , setChallenge: function (hostname, token, val, cb) {
var pathname = hostname + acme2.acmeChallengePrefix + token; var pathname;
console.log("Put the string '" + val + "' into a file at '" + pathname + "'");
console.log("echo '" + val + "' > '" + pathname + "'"); if ('http-01' === cb.type) {
pathname = hostname + acme2.acmeChallengePrefix + token;
console.log("Put the string '" + val /*keyAuthorization*/ + "' into a file at '" + pathname + "'");
console.log("echo '" + val /*keyAuthorization*/ + "' > '" + pathname + "'");
console.log("\nThen hit the 'any' key to continue..."); console.log("\nThen hit the 'any' key to continue...");
} else if ('dns-01' === cb.type) {
// forwards-backwards compat
pathname = acme2.challengePrefixes['dns-01'] + "." + hostname.replace(/^\*\./, '');
console.log("Put the string '" + cb.dnsAuthorization + "' into the TXT record '" + pathname + "'");
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"));
return;
}
function onAny() { function onAny() {
console.log("'any' key was hit"); console.log("'any' key was hit");

View File

@ -35,9 +35,9 @@ module.exports.run = function run(directoryUrl, RSA, web, chType, email, account
console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'"); console.log("Put the string '" + opts.keyAuthorization + "' into a file at '" + pathname + "'");
console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'"); console.log("echo '" + opts.keyAuthorization + "' > '" + pathname + "'");
} else if ('dns-01' === opts.type) { } else if ('dns-01' === opts.type) {
pathname = acme2.challengePrefixes['dns-01'] + "." + opts.hostname.replace(/^\*\./, '');; pathname = acme2.challengePrefixes['dns-01'] + "." + opts.hostname.replace(/^\*\./, '');
console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'"); console.log("Put the string '" + opts.dnsAuthorization + "' into the TXT record '" + pathname + "'");
console.log("ddig TXT " + pathname + " '" + opts.dnsAuthorization + "'"); console.log("dig TXT " + pathname + " '" + opts.dnsAuthorization + "'");
} else { } else {
reject(new Error("[acme-v2] unrecognized challenge type")); reject(new Error("[acme-v2] unrecognized challenge type"));
return; return;