diff --git a/lib/webroot.js b/lib/webroot.js index e2dba79..e900f92 100644 --- a/lib/webroot.js +++ b/lib/webroot.js @@ -9,9 +9,12 @@ module.exports.create = function (defaults) { // // set,get,remove challenges // - _challenges: {} - , setChallenge: function (args, key, value, cb) { - var challengePath = path.join(defaults.webrootPath, '.well-known', 'acme-challenge'); + getOptions: function () { + return { webrootPath: defaults.webrootPath }; + } + + , set: function (args, domain, token, secret, cb) { + var challengePath = path.join(args.webrootPath || defaults.webrootPath, '.well-known', 'acme-challenge'); mkdirp(challengePath, function (err) { if (err) { console.error("Could not create --webroot-path '" + challengePath + "':", err.code); @@ -20,11 +23,11 @@ module.exports.create = function (defaults) { return; } - var keyfile = path.join(challengePath, key); + var tokenfile = path.join(challengePath, token); - fs.writeFile(keyfile, value, 'utf8', function (err) { + fs.writeFile(tokenfile, secret, 'utf8', function (err) { if (err) { - console.error("Could not write '" + keyfile + "':", err.code); + console.error("Could not write '" + tokenfile + "':", err.code); cb(err); return; } @@ -33,14 +36,19 @@ module.exports.create = function (defaults) { }); }); } - // handled as file read by web server - // , getChallenge: function (args, key, cb) {} - , removeChallenge: function (args, key, cb) { - var keyfile = path.join(defaults.webrootPath, '.well-known', 'acme-challenge', key); - fs.unlink(keyfile, function (err) { + // handled as file read by web server + , get: function (args, domain, token, cb) { + // see https://github.com/Daplie/node-letsencrypt/issues/41 + cb(new Error("get not implemented (on purpose) in le-cli/lib/webroot.js")); + } + + , remove: function (args, domain, token, cb) { + var tokenfile = path.join(args.webrootPath || defaults.webrootPath, '.well-known', 'acme-challenge', token); + + fs.unlink(tokenfile, function (err) { if (err) { - console.error("Could not unlink '" + keyfile + "':", err.code); + console.error("Could not unlink '" + tokenfile + "':", err.code); cb(err); return; }