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

View File

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

20
package-lock.json generated
View File

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

View File

@ -1,22 +1,21 @@
{
"name": "le-challenge-manual",
"version": "3.0.3",
"name": "greenlock-challenge-manual",
"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.",
"main": "index.js",
"homepage": "https://git.coolaj86.com/coolaj86/le-challenge-manual.js",
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js",
"scripts": {
"test": "node test.js"
},
"repository": {
"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": [
"le-challenge",
"le-challenge-",
"Let's Encrypt",
"ACME",
"challenge",
"manual",
"acme",
"letsencrypt",
"certbot",
"cli",
"commandline"
@ -24,10 +23,10 @@
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "MPL-2.0",
"bugs": {
"url": "https://git.coolaj86.com/coolaj86/le-challenge-manual.js/issues"
"url": "https://git.coolaj86.com/coolaj86/greenlock-challenge-manual.js/issues"
},
"dependencies": {
"le-challenge-dns": "^3.0.3",
"le-challenge-http": "^3.0.0"
"greenlock-challenge-dns": "^3.0.3",
"greenlock-challenge-http": "^3.0.0"
}
}

55
test.js
View File

@ -1,50 +1,25 @@
'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() {
// this will cause the prompt to appear
return new Promise(function (resolve, reject) {
challenge.set(opts, function () {
// this will cause the final completion message to appear
return Promise.resolve(challenge.remove(opts)).then(resolve).catch(reject);
});
// The dry-run tests can pass on, literally, 'example.com'
// but the integration tests require that you have control over the domain
var domain = 'example.com';
var wildname = '*.example.com';
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 () {
console.info("PASS");
return tester.test('fake-01', domain, challenger).then(function () {
console.info("PASS fake-01");
});
}).catch(function (err) {
console.error("FAIL");
console.error(err);
process.exit(17);
process.exit(20);
});