Browse Source

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

master v3.0.1
AJ ONeal 5 years ago
parent
commit
4ee2f81535
  1. 16
      README.md
  2. 12
      index.js
  3. 4
      package-lock.json
  4. 10
      package.json
  5. 33
      test.js

16
README.md

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

12
index.js

@ -92,11 +92,15 @@ Challenge._removeHttp = function (args) {
Challenge._getHttp = function (args) {
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]) {
Challenge._getCache[ch.altname + ':' + ch.token] = true;
console.log(args);
if (ch._test || !Challenge._getCache[ch.token]) {
Challenge._getCache[ch.token] = true;
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)");
process.stdout.write("> ");
}
@ -109,7 +113,7 @@ Challenge._getHttp = function (args) {
process.stdin.once('data', function (chunk) {
process.stdin.pause();
var result = chunk.toString('utf8');
var result = chunk.toString('utf8').trim();
try {
result = JSON.parse(result);
} catch(e) {

4
package-lock.json

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

10
package.json

@ -1,15 +1,15 @@
{
"name": "le-challenge-http",
"version": "3.0.0",
"name": "greenlock-challenge-http",
"version": "3.0.1",
"description": "A very simple reference implementation of an ACME http-01 challenge for Greenlock v2.7+ (and v3)",
"main": "index.js",
"homepage": "https://git.coolaj86.com/coolaj86/le-challenge-http.js",
"homepage": "https://git.coolaj86.com/coolaj86/greenlock-challenge-http.js",
"scripts": {
"test": "node test.js"
},
"repository": {
"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": [
"Let's Encrypt",
@ -23,6 +23,6 @@
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "MPL-2.0",
"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';
/*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() {
// 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';
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'
};
run(opts).then(function () {
tester.test(type, domain, challenger).then(function () {
console.info("PASS");
}).catch(function (err) {
console.error("FAIL");

Loading…
Cancel
Save