Этот коммит содержится в:
AJ ONeal 2016-08-05 03:54:57 -04:00
родитель 17acb32488
Коммит d5ab9de773
2 изменённых файлов: 86 добавлений и 1 удалений

Просмотреть файл

@ -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

40
index.js Обычный файл
Просмотреть файл

@ -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);
};