This commit is contained in:
AJ ONeal 2019-04-06 02:17:56 -06:00
parent b5b11a7779
commit 6db2e9b308
3 changed files with 10 additions and 21 deletions

View File

@ -6,6 +6,10 @@ An extremely simple reference implementation
of an ACME (Let's Encrypt) http-01 challenge strategy
for [Greenlock](https://git.coolaj86.com/coolaj86/greenlock-express.js) v2.7+ (and v3).
```
GET http://example.com/.well-known/acme-challenge/xxxxxxxxxxxxxxxx
```
* Prints the ACME challenge URL and Key Authorization to the terminal
* (waits for you to hit enter before continuing)
* Asks you to enter (or upload) the Key Authorization challenge response.

View File

@ -40,6 +40,7 @@ Challenge.create = function (config) {
// Prints the challenge URL and keyAuthorization to the screen
// (so that you can go set it and then continue)
// if you need per-run / per-domain options set them in approveDomains() and they'll be on 'args' here.
Challenge._setHttp = function (args, cb) {
// Note: You can receive cb and use that, or omit cb and return a Promise
@ -79,7 +80,7 @@ Challenge._removeHttp = function (args) {
var ch = args.challenge;
console.info("");
console.info("[ACME http-01 '" + ch.altname + "' COMPLETE]");
console.info("[ACME http-01 '" + ch.altname + "' COMPLETE]: " + ch.status);
console.info("Challenge complete. You may now remove the challenge file:");
console.info("");
console.info('\thttp://' + ch.altname + '/.well-known/acme-challenge/' + ch.token);
@ -89,9 +90,7 @@ Challenge._removeHttp = function (args) {
return null;
};
// nothing to do here, that's why it's manual
Challenge._getHttp = function (args) {
// Note: Here I'm You can receive cb and use that, or omit cb and return a Promise
var ch = args.challenge;
if (!Challenge._getCache[ch.altname + ':' + ch.token]) {

22
test.js
View File

@ -16,35 +16,21 @@ function run() {
}
opts.challenge = {
type: 'http-01'
type: 'dns-01'
, identifier: { type: 'dns', value: 'example.com' }
, wildcard: false
, wildcard: true
, expires: '2012-01-01T12:00:00.000Z'
, token: 'abc123'
, thumbprint: '<<account key thumbprint>>'
, keyAuthorization: 'abc123.xxxx'
, dnsHost: '_acme-challenge.example.com'
, dnsAuthorization: 'yyyy'
, altname: 'example.com'
, altname: '*.example.com'
};
run(opts).then(function () {
opts.challenge = {
type: 'dns-01'
, identifier: { type: 'dns', value: 'example.com' }
, wildcard: true
, expires: '2012-01-01T12:00:00.000Z'
, token: 'abc123'
, thumbprint: '<<account key thumbprint>>'
, keyAuthorization: 'abc123.xxxx'
, dnsHost: '_acme-challenge.example.com'
, dnsAuthorization: 'yyyy'
, altname: '*.example.com'
};
return run(opts);
}).then(function () {
console.info("PASS");
}).catch(function (err) {
console.error("FAIL");
console.error(err);
process.exit(17);
process.exit(19);
});