v2.0.0
This commit is contained in:
parent
aecf64ffbe
commit
f8fc01c5f0
58
README.md
58
README.md
@ -1,2 +1,56 @@
|
|||||||
# le-challenge-memory
|
[](https://gitter.im/Daplie/letsencrypt-express?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
A memory-based strategy for node-letsencrypt for setting, retrieving, and clearing ACME challenges issued by the ACME server
|
|
||||||
|
| [letsencrypt](https://github.com/Daplie/node-letsencrypt) (library)
|
||||||
|
| [letsencrypt-cli](https://github.com/Daplie/letsencrypt-cli)
|
||||||
|
| [letsencrypt-express](https://github.com/Daplie/letsencrypt-express)
|
||||||
|
| [letsencrypt-koa](https://github.com/Daplie/letsencrypt-koa)
|
||||||
|
| [letsencrypt-hapi](https://github.com/Daplie/letsencrypt-hapi)
|
||||||
|
|
|
||||||
|
|
||||||
|
le-challenge-memory
|
||||||
|
===================
|
||||||
|
|
||||||
|
An in-memory strategy for node-letsencrypt for setting, retrieving,
|
||||||
|
and clearing ACME challenges issued by the ACME server
|
||||||
|
|
||||||
|
* Safe to use on ephemeral services (i.e. AWS)
|
||||||
|
* DO NOT use with node cluester (i.e. letsencrypt-cluster)
|
||||||
|
|
||||||
|
Install
|
||||||
|
-------
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install --save le-challenge-standalone@2.x
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
```bash
|
||||||
|
var leChallenge = require('le-challenge-standalone').create({
|
||||||
|
, debug: false
|
||||||
|
});
|
||||||
|
|
||||||
|
var LE = require('letsencrypt');
|
||||||
|
|
||||||
|
LE.create({
|
||||||
|
server: LE.stagingServerUrl
|
||||||
|
, challenge: leChallenge
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: If you request a certificate with 6 domains listed,
|
||||||
|
it will require 6 individual challenges.
|
||||||
|
|
||||||
|
Exposed Methods
|
||||||
|
---------------
|
||||||
|
|
||||||
|
For ACME Challenge:
|
||||||
|
|
||||||
|
* `set(opts, domain, key, val, done)`
|
||||||
|
* `get(defaults, domain, key, done)`
|
||||||
|
* `remove(defaults, domain, key, done)`
|
||||||
|
|
||||||
|
For node-letsencrypt internals:
|
||||||
|
|
||||||
|
* `getOptions()` returns the user supplied options, if any (no effect)
|
||||||
|
32
index.js
Normal file
32
index.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports.create = function (defaults) {
|
||||||
|
var handlers = {
|
||||||
|
getOptions: function () {
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// set,get,remove challenges
|
||||||
|
//
|
||||||
|
// Note: this is fine for a one-off CLI tool
|
||||||
|
// but a webserver using node-cluster or multiple
|
||||||
|
// servers should use a database of some sort
|
||||||
|
, _challenges: {}
|
||||||
|
, set: function (args, domain, token, secret, cb) {
|
||||||
|
handlers._challenges[token] = secret;
|
||||||
|
cb(null);
|
||||||
|
}
|
||||||
|
, get: function (args, domain, token, cb) {
|
||||||
|
// TODO keep in mind that, generally get args are just args.domains
|
||||||
|
// and it is disconnected from the flow of setChallenge and removeChallenge
|
||||||
|
cb(null, handlers._challenges[token]);
|
||||||
|
}
|
||||||
|
, remove: function (args, domain, token, cb) {
|
||||||
|
delete handlers._challenges[token];
|
||||||
|
cb(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return handlers;
|
||||||
|
};
|
29
package.json
Normal file
29
package.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "le-challenge-standalone",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "An in-memory strategy for node-letsencrypt for setting, retrieving, and clearing ACME challenges issued by the ACME server.",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "node test.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/Daplie/le-challenge-memory.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"le-challenge",
|
||||||
|
"le-challenge-",
|
||||||
|
"memory",
|
||||||
|
"in-memory",
|
||||||
|
"standalone",
|
||||||
|
"ACME",
|
||||||
|
"letsencrypt",
|
||||||
|
"certbot"
|
||||||
|
],
|
||||||
|
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
|
||||||
|
"license": "(MIT OR Apache-2.0)",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/Daplie/le-challenge-memory/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/Daplie/le-challenge-memory#readme"
|
||||||
|
}
|
51
test.js
Normal file
51
test.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var challenge = require('./').create({ debug: true, webrootPath: '/tmp/acme-challenge' });
|
||||||
|
|
||||||
|
var opts = challenge.getOptions();
|
||||||
|
var domain = 'example.com';
|
||||||
|
var token = 'token-id';
|
||||||
|
var key = 'secret-key';
|
||||||
|
|
||||||
|
challenge.remove(opts, domain, token, function () {
|
||||||
|
// ignore error, if any
|
||||||
|
|
||||||
|
challenge.set(opts, domain, token, key, function (err) {
|
||||||
|
// if there's an error, there's a problem
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// throw new Error("manually check /tmp/acme-challenge");
|
||||||
|
|
||||||
|
challenge.get(opts, domain, token, function (err, _key) {
|
||||||
|
// if there's an error, there's a problem
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// should retrieve the key
|
||||||
|
if (key !== _key) {
|
||||||
|
throw new Error("FAIL: could not get key by token");
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge.remove(opts, domain, token, function () {
|
||||||
|
// if there's an error, there's a problem
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
challenge.get(opts, domain, token, function (err, _key) {
|
||||||
|
// error here is okay
|
||||||
|
|
||||||
|
// should NOT retrieve the key
|
||||||
|
if (_key) {
|
||||||
|
throw new Error("FAIL: should not get key");
|
||||||
|
}
|
||||||
|
|
||||||
|
console.info('PASS');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user