v3.0.1: ACME http-01 challenge reference implementation for Greenlock v2.7+ (and v3)

This commit is contained in:
AJ ONeal 2019-04-07 17:31:03 -06:00
джерело 6db2e9b308
коміт 4ee2f81535
5 змінених файлів з 31 додано та 44 видалено

@ -1,4 +1,4 @@
# [le-challenge-http](https://git.coolaj86.com/coolaj86/le-challenge-http.js) # [greenlock-challenge-http](https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js)
| A [Root](https://rootprojects.org) Project | | A [Root](https://rootprojects.org) Project |
@ -17,15 +17,15 @@ GET http://example.com/.well-known/acme-challenge/xxxxxxxxxxxxxxxx
Other ACME Challenge Reference Implementations: Other ACME Challenge Reference Implementations:
* [le-challenge-manual](https://git.coolaj86.com/coolaj86/le-challenge-manual.js.git) * [greenlock-challenge-manual](https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js.git)
* [**le-challenge-http**](https://git.coolaj86.com/coolaj86/le-challenge-http.js.git) * [**greenlock-challenge-http**](https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js.git)
* [le-challenge-dns](https://git.coolaj86.com/coolaj86/le-challenge-dns.js.git) * [greenlock-challenge-dns](https://git.coolaj86.com/coolaj86/greenlock-challenge-dns.js.git)
Install Install
------- -------
```bash ```bash
npm install --save le-challenge-http@3.x npm install --save greenlock-challenge-http@3.x
``` ```
Usage Usage
@ -36,9 +36,9 @@ var Greenlock = require('greenlock');
Greenlock.create({ Greenlock.create({
... ...
, challenges: { 'http-01': require('le-challenge-http').create({ debug: true }) , challenges: { 'http-01': require('greenlock-challenge-http').create({ debug: true })
, 'dns-01': require('le-challenge-dns') , 'dns-01': require('greenlock-challenge-dns')
, 'tls-alpn-01': require('le-challenge-manual') , 'tls-alpn-01': require('greenlock-challenge-manual')
} }
... ...
}); });

@ -92,11 +92,15 @@ Challenge._removeHttp = function (args) {
Challenge._getHttp = function (args) { Challenge._getHttp = function (args) {
var ch = args.challenge; var ch = args.challenge;
var altname = ch.altname || ch.identifier.value;
var hostname = ch.hostname || ch.identifier.value;
if (!Challenge._getCache[ch.altname + ':' + ch.token]) { console.log(args);
Challenge._getCache[ch.altname + ':' + ch.token] = true; if (ch._test || !Challenge._getCache[ch.token]) {
Challenge._getCache[ch.token] = true;
console.info(""); console.info("");
console.info('GET http://' + ch.altname + '/.well-known/acme-challenge/' + ch.token); console.info("[ACME " + ch.type + " '" + altname + "' REQUEST]: " + ch.status);
console.info('GET http://' + hostname + '/.well-known/acme-challenge/' + ch.token);
console.info("(paste in the \"Key Authorization\" you received a moment ago to respond)"); console.info("(paste in the \"Key Authorization\" you received a moment ago to respond)");
process.stdout.write("> "); process.stdout.write("> ");
} }
@ -109,7 +113,7 @@ Challenge._getHttp = function (args) {
process.stdin.once('data', function (chunk) { process.stdin.once('data', function (chunk) {
process.stdin.pause(); process.stdin.pause();
var result = chunk.toString('utf8'); var result = chunk.toString('utf8').trim();
try { try {
result = JSON.parse(result); result = JSON.parse(result);
} catch(e) { } catch(e) {

4
package-lock.json згенерований

@ -1,5 +1,5 @@
{ {
"name": "le-challenge-manual", "name": "greenlock-challenge-http",
"version": "2.1.1", "version": "3.0.0",
"lockfileVersion": 1 "lockfileVersion": 1
} }

@ -1,15 +1,15 @@
{ {
"name": "le-challenge-http", "name": "greenlock-challenge-http",
"version": "3.0.0", "version": "3.0.1",
"description": "A very simple reference implementation of an ACME http-01 challenge for Greenlock v2.7+ (and v3)", "description": "A very simple reference implementation of an ACME http-01 challenge for Greenlock v2.7+ (and v3)",
"main": "index.js", "main": "index.js",
"homepage": "https://git.coolaj86.com/coolaj86/le-challenge-http.js", "homepage": "https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js",
"scripts": { "scripts": {
"test": "node test.js" "test": "node test.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://git.coolaj86.com/coolaj86/le-challenge-http.js.git" "url": "https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js.git"
}, },
"keywords": [ "keywords": [
"Let's Encrypt", "Let's Encrypt",
@ -23,6 +23,6 @@
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)", "author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "MPL-2.0", "license": "MPL-2.0",
"bugs": { "bugs": {
"url": "https://git.coolaj86.com/coolaj86/le-challenge-http.js/issues" "url": "https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js/issues"
} }
} }

33
test.js

@ -1,33 +1,16 @@
'use strict'; 'use strict';
/*global Promise*/
var challenge = require('./').create({}); var tester = require('greenlock-challenge-test');
var opts = challenge.getOptions && challenge.getOptions() || challenge.options; var type = 'http-01';
//var challenger = require('greenlock-challenge-http').create({});
var challenger = require('./').create({});
function run() { // The dry-run tests can pass on, literally, 'example.com'
// this will cause the prompt to appear // but the integration tests require that you have control over the domain
return new Promise(function (resolve, reject) { var domain = 'example.com';
challenge.set(opts, function () {
// this will cause the final completion message to appear
return Promise.resolve(challenge.remove(opts)).then(resolve).catch(reject);
});
});
}
opts.challenge = { tester.test(type, domain, challenger).then(function () {
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'
};
run(opts).then(function () {
console.info("PASS"); console.info("PASS");
}).catch(function (err) { }).catch(function (err) {
console.error("FAIL"); console.error("FAIL");