initial commit
This commit is contained in:
parent
17acb32488
commit
d5ab9de773
47
README.md
47
README.md
|
@ -1,2 +1,47 @@
|
|||
# le-challenge-fs
|
||||
A fs-based strategy for node-letsencrypt for setting, retrieving, and clearing ACME challenges issued by the ACME server
|
||||
|
||||
A fs-based strategy for node-letsencrypt for setting, retrieving,
|
||||
and clearing ACME challenges issued by the ACME server
|
||||
|
||||
This places the acme challenge in an appropriate directory in the specified `webrootPath`
|
||||
and removes it once the challenge has either completed or failed.
|
||||
|
||||
* Safe to use with node cluster
|
||||
* Safe to use with ephemeral services (Heroku, Joyent, etc)
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
```bash
|
||||
npm install --save le-challenge-fs@2.x
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
```bash
|
||||
var leChallenge = require('le-challenge-fs').create({
|
||||
webrootPath: '~/letsencrypt/srv/www/:hostname/.well-known/acme-challenge'
|
||||
, debug: false
|
||||
});
|
||||
|
||||
var LE = require('letsencrypt');
|
||||
|
||||
LE.create({
|
||||
server: LE.stagingServerUrl // Change to LE.productionServerUrl in production
|
||||
, challenge: leChallenge
|
||||
});
|
||||
```
|
||||
|
||||
Exposed Methods
|
||||
---------------
|
||||
|
||||
For ACME Challenge:
|
||||
|
||||
* `setChallange(opts, domain, key, val, done)`
|
||||
* `getChallange(domain, key, done)`
|
||||
* `removeChallange(domain, key, done)`
|
||||
|
||||
For node-letsencrypt internals:
|
||||
|
||||
* `getOptions()` returns the internal defaults merged with the user-supplied options
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
module.exports.agreeToTerms = function (args, agreeCb) {
|
||||
agreeCb(null, args.agreeTos);
|
||||
};
|
||||
|
||||
module.exports.setChallenge = function (args, domain, challengePath, keyAuthorization, done) {
|
||||
//var hostname = args.domains[0];
|
||||
var mkdirp = require('mkdirp');
|
||||
|
||||
// TODO should be args.webrootPath
|
||||
//console.log('args.webrootPath, challengePath');
|
||||
//console.log(args.webrootPath, challengePath);
|
||||
mkdirp(args.webrootPath, function (err) {
|
||||
if (err) {
|
||||
done(err);
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFile(path.join(args.webrootPath, challengePath), keyAuthorization, 'utf8', function (err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.getChallenge = function (args, domain, key, done) {
|
||||
//var hostname = args.domains[0];
|
||||
|
||||
//console.log("getting the challenge", args, key);
|
||||
fs.readFile(path.join(args.webrootPath, key), 'utf8', done);
|
||||
};
|
||||
|
||||
module.exports.removeChallenge = function (args, domain, key, done) {
|
||||
//var hostname = args.domains[0];
|
||||
|
||||
fs.unlink(path.join(args.webrootPath, key), done);
|
||||
};
|
Loading…
Reference in New Issue