This commit is contained in:
AJ ONeal 2015-12-15 12:01:05 +00:00
parent d4a44f893c
commit 1ad3e6f2f2
7 changed files with 38 additions and 35 deletions

View File

@ -3,7 +3,7 @@
var PromiseA = require('bluebird'); var PromiseA = require('bluebird');
var path = require('path'); var path = require('path');
var fs = PromiseA.promisifyAll(require('fs')); var fs = PromiseA.promisifyAll(require('fs'));
var cutils = PromiseA.promisifyAll(require('crypto-utils-ursa')); var cutils = PromiseA.promisifyAll(require('../lib/crypto-utils-ursa'));
//var futils = require('letsencrypt-forge/lib/crypto-utils'); //var futils = require('letsencrypt-forge/lib/crypto-utils');
var requestAsync = PromiseA.promisify(require('request')); var requestAsync = PromiseA.promisify(require('request'));
var lef = PromiseA.promisifyAll(require('letsencrypt-forge')); var lef = PromiseA.promisifyAll(require('letsencrypt-forge'));

View File

@ -44,14 +44,14 @@ LE.create = function (backend, defaults, handlers) {
// GET /.well-known/acme-challenge/{{challengeKey}} should return {{tokenValue}} // GET /.well-known/acme-challenge/{{challengeKey}} should return {{tokenValue}}
throw new Error("handlers.setChallenge or defaults.webrootPath must be set"); throw new Error("handlers.setChallenge or defaults.webrootPath must be set");
} }
handlers.setChallenge = require('lib/default-set-challenge'); handlers.setChallenge = require('./lib/default-handlers').setChallenge;
} }
if (!handlers.removeChallenge) { if (!handlers.removeChallenge) {
if (!defaults.webrootPath) { if (!defaults.webrootPath) {
// GET /.well-known/acme-challenge/{{challengeKey}} should return {{tokenValue}} // GET /.well-known/acme-challenge/{{challengeKey}} should return {{tokenValue}}
throw new Error("handlers.setChallenge or defaults.webrootPath must be set"); throw new Error("handlers.setChallenge or defaults.webrootPath must be set");
} }
handlers.removeChallenge = require('lib/default-remove-challenge'); handlers.removeChallenge = require('./lib/default-handlers').remove-Challenge;
} }
if (!handlers.agreeToTerms) { if (!handlers.agreeToTerms) {
if (defaults.agreeTos) { if (defaults.agreeTos) {

View File

@ -1,5 +1,37 @@
'use strict'; 'use strict';
var fs = require('fs');
var path = require('path');
module.exports.agreeToTerms = function (args, agree) { module.exports.agreeToTerms = function (args, agree) {
agree(args.agreeTos || args.agree); agree(args.agreeTos);
};
module.exports.setChallenge = function (args, challengePath, keyAuthorization, done) {
//var hostname = args.domains[0];
var mkdirp = require('mkdirp');
// TODO should be args.webrootPath
mkdirp(path.join(args.webrootPath, challengePath), 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, key, done) {
//var hostname = args.domains[0];
fs.readFile(path.join(args.webroot, key), 'utf8', done);
};
module.exports.removeChallenge = function (args, key, done) {
//var hostname = args.domains[0];
fs.unlinkSync(path.join(args.webroot, key), done);
}; };

View File

@ -1,10 +0,0 @@
'use strict';
var path = require('path');
var fs = require('fs');
module.exports = function (args, key, done) {
//var hostname = args.domains[0];
fs.unlinkSync(path.join(args.webroot, key), done);
};

View File

@ -1,21 +0,0 @@
'use strict';
var fs = require('fs');
var path = require('path');
module.exports = function (args, challengePath, keyAuthorization, done) {
//var hostname = args.domains[0];
var mkdirp = require('mkdirp');
// TODO should be args.webrootPath
mkdirp(path.join(args.webrootPath, challengePath), function (err) {
if (err) {
done(err);
return;
}
fs.writeFile(path.join(args.webrootPath, challengePath), keyAuthorization, 'utf8', function (err) {
done(err);
});
});
};

View File

@ -43,7 +43,9 @@
}, },
"dependencies": { "dependencies": {
"bluebird": "^3.0.6", "bluebird": "^3.0.6",
"mkdirp": "^0.5.1",
"pyconf": "^1.0.0", "pyconf": "^1.0.0",
"request": "^2.67.0",
"safe-replace": "^1.0.0", "safe-replace": "^1.0.0",
"serve-static": "^1.10.0" "serve-static": "^1.10.0"
} }