v3.0.4: ACME challenge reference implementation for Greenlock v2.7+ (and v3)

This commit is contained in:
AJ ONeal 2019-04-07 17:43:47 -06:00
parent d5d44ea2d2
commit 0997ac76cf
5 changed files with 46 additions and 72 deletions

View File

@ -1,4 +1,4 @@
# [le-challenge-manual](https://git.coolaj86.com/coolaj86/le-challenge-manual.js) # [greenlock-challenge-manual](https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js)
| A [Root](https://rootprojects.org) Project | | A [Root](https://rootprojects.org) Project |
@ -13,15 +13,15 @@ for [Greenlock](https://git.coolaj86.com/coolaj86/greenlock-express.js) v2.7+ (a
Other ACME Challenge Reference Implementations: Other ACME Challenge Reference Implementations:
* [**le-challenge-manual**](https://git.coolaj86.com/coolaj86/le-challenge-manual.js) * [**greenlock-challenge-manual**](https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js)
* [le-challenge-http](https://git.coolaj86.com/coolaj86/le-challenge-http.js) * [greenlock-challenge-http](https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js)
* [le-challenge-dns](https://git.coolaj86.com/coolaj86/le-challenge-dns.js) * [greenlock-challenge-dns](https://git.coolaj86.com/coolaj86/greenlock-challenge-dns.js)
Install Install
------- -------
```bash ```bash
npm install --save le-challenge-manual@3.x npm install --save greenlock-challenge-manual@3.x
``` ```
Usage Usage
@ -32,9 +32,9 @@ var Greenlock = require('greenlock');
Greenlock.create({ Greenlock.create({
... ...
, challenges: { 'http-01': require('le-challenge-manual') , challenges: { 'http-01': require('greenlock-challenge-manual')
, 'dns-01': require('le-challenge-manual') , 'dns-01': require('greenlock-challenge-manual')
, 'tls-alpn-01': require('le-challenge-manual') , 'tls-alpn-01': require('greenlock-challenge-manual')
} }
... ...
}); });

View File

@ -6,8 +6,8 @@ var Challenge = module.exports;
Challenge.create = function (config) { Challenge.create = function (config) {
// If your implementation needs config options, set them. Otherwise, don't bother (duh). // If your implementation needs config options, set them. Otherwise, don't bother (duh).
var http01 = require('le-challenge-http').create(config); var http01 = require('greenlock-challenge-http').create(config);
var dns01 = require('le-challenge-dns').create(config); var dns01 = require('greenlock-challenge-dns').create(config);
var challenger = {}; var challenger = {};
@ -114,7 +114,7 @@ Challenge._get = function (args) {
process.stdin.once('error', reject); process.stdin.once('error', reject);
process.stdin.once('data', function (chunk) { process.stdin.once('data', function (chunk) {
process.stdin.pause(); process.stdin.pause();
var result = chunk.toString(); var result = chunk.toString('utf8').trim();
try { try {
result = JSON.parse(result); result = JSON.parse(result);
} catch(e) { } catch(e) {

20
package-lock.json generated
View File

@ -1,18 +1,18 @@
{ {
"name": "le-challenge-manual", "name": "greenlock-challenge-manual",
"version": "3.0.2", "version": "3.0.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"le-challenge-dns": { "greenlock-challenge-dns": {
"version": "3.0.3", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/le-challenge-dns/-/le-challenge-dns-3.0.3.tgz", "resolved": "https://registry.npmjs.org/greenlock-challenge-dns/-/greenlock-challenge-dns-3.0.4.tgz",
"integrity": "sha512-6jz9YMpWhTXJKK+Id/S0j8R3oEiH6ya5WBTPzc7GsNR21voesejP7UJaDcdH9GQrjf7gBX3xyr4BlL/GplNBOw==" "integrity": "sha512-CJI9RAtrZl9ICldyU5cRGzb1/wIbS3O+MJy9z7gKb7fLDNF7Wmw9Fv2agBLSOtIPr7TYgyyesvt8ppA4OIS+yg=="
}, },
"le-challenge-http": { "greenlock-challenge-http": {
"version": "3.0.0", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/le-challenge-http/-/le-challenge-http-3.0.0.tgz", "resolved": "https://registry.npmjs.org/greenlock-challenge-http/-/greenlock-challenge-http-3.0.1.tgz",
"integrity": "sha512-kQb2j/lftI6mRjHy5AqueOkqjlcyfLlAF3Nk468xjloG0JGadjK4iT23mlXTaBIg84OIpPlhRuS+XNs5uhn8Xw==" "integrity": "sha512-u+r8VtT+Qve0wucVZEPivFRT7DP+Jfl7McGMbna0BFVvAc+NJyOJGyvBa6aGDi4qgEhx7pjh0yCsCEKDHI2zDw=="
} }
} }
} }

View File

@ -1,22 +1,21 @@
{ {
"name": "le-challenge-manual", "name": "greenlock-challenge-manual",
"version": "3.0.3", "version": "3.0.4",
"description": "A cli-based strategy for node-letsencrypt. Prints the ACME challenge Token and Key and then waits for you to hit enter before continuing.", "description": "A cli-based strategy for node-letsencrypt. Prints the ACME challenge Token and Key and then waits for you to hit enter before continuing.",
"main": "index.js", "main": "index.js",
"homepage": "https://git.coolaj86.com/coolaj86/le-challenge-manual.js", "homepage": "https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.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-manual.js.git" "url": "https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js.git"
}, },
"keywords": [ "keywords": [
"le-challenge", "Let's Encrypt",
"le-challenge-", "ACME",
"challenge",
"manual", "manual",
"acme",
"letsencrypt",
"certbot", "certbot",
"cli", "cli",
"commandline" "commandline"
@ -24,10 +23,10 @@
"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-manual.js/issues" "url": "https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js/issues"
}, },
"dependencies": { "dependencies": {
"le-challenge-dns": "^3.0.3", "greenlock-challenge-dns": "^3.0.3",
"le-challenge-http": "^3.0.0" "greenlock-challenge-http": "^3.0.0"
} }
} }

55
test.js
View File

@ -1,50 +1,25 @@
'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 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 () { var wildname = '*.example.com';
// this will cause the final completion message to appear
return Promise.resolve(challenge.remove(opts)).then(resolve).catch(reject); tester.test('http-01', domain, challenger).then(function () {
}); console.info("PASS http-01");
return tester.test('dns-01', wildname, challenger).then(function () {
console.info("PASS dns-01");
}); });
}
opts.challenge = {
type: 'http-01'
, identifier: { type: 'dns', value: 'example.com' }
, wildcard: false
, 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 () {
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 () { }).then(function () {
console.info("PASS"); return tester.test('fake-01', domain, challenger).then(function () {
console.info("PASS fake-01");
});
}).catch(function (err) { }).catch(function (err) {
console.error("FAIL"); console.error("FAIL");
console.error(err); console.error(err);
process.exit(17); process.exit(20);
}); });