69 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-09-07 14:58:25 -06:00
'use strict';
var Challenge = module.exports;
2016-10-14 20:08:21 -06:00
Challenge.create = function (defaults) {
2019-04-04 10:35:06 -06:00
// if you need special options that apply to all domains, you could set them here.
2017-04-19 16:51:48 -05:00
return {
2019-04-02 20:59:11 -06:00
options: defaults
2016-10-14 20:08:21 -06:00
, set: Challenge.set
, get: Challenge.get
, remove: Challenge.remove
2016-09-07 14:58:25 -06:00
};
};
2016-10-14 20:08:21 -06:00
// Show the user the token and key and wait for them to be ready to continue
2019-04-02 20:59:11 -06:00
Challenge.set = function (args, cb) {
2019-04-04 10:35:06 -06:00
// if you need per-run / per-domain options set them in approveDomains() and they'll be on 'args' here.
2019-04-02 20:59:11 -06:00
if (!args.challenge) {
console.error("please update to greenlock v2.7+");
process.exit();
}
var opts = args.challenge;
2016-10-14 20:08:21 -06:00
2017-06-19 15:44:55 -07:00
if (this.leDnsResponse) {
2019-04-02 20:59:11 -06:00
this.leDnsResponse(opts.token, opts.keyAuthorization, opts.dnsAuthorization, opts.dnsHost, opts.altname)
2018-05-12 19:17:26 -06:00
.then(function (/*successMessage*/) {
2017-06-19 15:44:55 -07:00
cb(null);
});
} else {
console.info("");
2019-04-04 10:35:06 -06:00
console.info("We now present (for your copy-and-paste pleasure)...");
console.info("DNS-01 ACME (Let's Encrypt) Challenge for '" + opts.altname + "'");
2017-06-19 15:44:55 -07:00
console.info("");
2019-04-02 20:59:11 -06:00
console.info(opts.dnsHost + "\tTXT " + opts.dnsAuthorization + "\tTTL 60");
2017-06-19 15:44:55 -07:00
console.info("");
console.info(JSON.stringify({
2019-04-02 20:59:11 -06:00
identifier: opts.identifier
, wildcard: opts.wildcard
, altname: opts.altname
, type: opts.type
, token: opts.token
, keyAuthorization: opts.keyAuthorization
, dnsHost: opts.dnsHost
, dnsAuthorization: opts.dnsAuthorization
, expires: opts.expires
2017-06-19 15:44:55 -07:00
}, null, ' ').replace(/^/gm, '\t'));
console.info("");
2019-04-04 10:35:06 -06:00
console.info("Insert quarter, er... I mean hit the any key to continue...");
2017-06-19 15:44:55 -07:00
process.stdin.resume();
process.stdin.on('data', function () {
process.stdin.pause();
cb(null);
});
}
2016-09-07 14:58:25 -06:00
};
2019-04-04 10:35:06 -06:00
// nothing to do here (that's the dns server's job), that's why it's manual
2019-04-02 20:59:11 -06:00
Challenge.get = function (defaults, cb) {
// defaults.challenge
2016-10-14 20:08:21 -06:00
cb(null);
2016-09-07 14:58:25 -06:00
};
2016-10-14 20:08:21 -06:00
// might as well tell the user that whatever they were setting up has been checked
2019-04-02 20:59:11 -06:00
Challenge.remove = function (args, cb) {
2019-04-04 10:35:06 -06:00
console.info("Success. You may now remove the DNS-01 challenge record:");
2019-04-02 20:59:11 -06:00
console.info("\t" + args.challenge.altname + "\tTXT\t" + args.challenge.dnsAuthorization);
cb(null);
2016-09-07 14:58:25 -06:00
};