making way for forge and ursa backends

This commit is contained in:
AJ ONeal 2015-12-14 21:21:59 -08:00
parent efcc2b3bac
commit 050ec1f1f3
7 changed files with 46 additions and 19 deletions

View File

@ -3,11 +3,12 @@
var PromiseA = require('bluebird'); var PromiseA = require('bluebird');
var fs = PromiseA.promisifyAll(require('fs')); var fs = PromiseA.promisifyAll(require('fs'));
module.exports.create = function (leBinPath, defaults, opts) { module.exports.create = function (defaults, opts) {
defaults.webroot = true; defaults.webroot = true;
defaults.renewByDefault = true; defaults.renewByDefault = true;
defaults.text = true; defaults.text = true;
var leBinPath = defaults.pythonClientPath;
var LEP = require('letsencrypt-python'); var LEP = require('letsencrypt-python');
var lep = PromiseA.promisifyAll(LEP.create(leBinPath, opts)); var lep = PromiseA.promisifyAll(LEP.create(leBinPath, opts));
var wrapped = { var wrapped = {

View File

@ -23,17 +23,18 @@ var bkDefaults = {
, fullchainTpl: '/live/:hostname/fullchain.pem' , fullchainTpl: '/live/:hostname/fullchain.pem'
, privkeyTpl: '/live/:hostname/privkey.pem' , privkeyTpl: '/live/:hostname/privkey.pem'
, configDir: path.join(__dirname, '..', 'tests', 'letsencrypt.config') , configDir: path.join(__dirname, '..', 'tests', 'letsencrypt.config')
, server: LE.stagingServer
// backend-specific
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs') , logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work') , workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
, server: LE.stagingServer
, text: true , text: true
, pythonClientPath: require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'
}; };
var leBinPath = require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'; var LEP = require('../backends/python');
var LEB = require('../backends-python');
var backend = LEB.create(leBinPath, bkDefaults, { debug: true });
var le = LE.create(backend, bkDefaults, { var le = LE.create(LEP, bkDefaults, {
/* /*
setChallenge: function (hostnames, key, value, cb) { setChallenge: function (hostnames, key, value, cb) {
// the python backend needs fs.watch implemented // the python backend needs fs.watch implemented

View File

@ -21,11 +21,12 @@ var config = {
// these are specific to the python client and won't be needed with the purejs library // these are specific to the python client and won't be needed with the purejs library
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs') , logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work') , workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
, pythonClientPath: binpath
} }
}; };
//config.backend = require('letsencrypt/backends-python').create(binpath, config.le); //config.backend = require('letsencrypt/backends/python').create(binpath, config.le);
config.backend = require('../backends-python').create(binpath, config.le); config.backend = require('../backends/python');
module.exports = config; module.exports = config;

View File

@ -23,16 +23,17 @@ var bkDefaults = {
, fullchainTpl: '/live/:hostname/fullchain.pem' , fullchainTpl: '/live/:hostname/fullchain.pem'
, privkeyTpl: '/live/:hostname/privkey.pem' , privkeyTpl: '/live/:hostname/privkey.pem'
, configDir: path.join(__dirname, '..', 'tests', 'letsencrypt.config') , configDir: path.join(__dirname, '..', 'tests', 'letsencrypt.config')
, server: LE.stagingServer
// python-specific
, logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs') , logsDir: path.join(__dirname, '..', 'tests', 'letsencrypt.logs')
, workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work') , workDir: path.join(__dirname, '..', 'tests', 'letsencrypt.work')
, server: LE.stagingServer , pythonClientPath: require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'
}; };
var leBinPath = require('os').homedir() + '/.local/share/letsencrypt/bin/letsencrypt'; var LEP = require('../backends/python');
var LEB = require('../backends-python');
var backend = LEB.create(leBinPath, bkDefaults, { debug: true });
var le = LE.create(backend, bkDefaults, { var le = LE.create(LEP, bkDefaults, {
sniRegisterCallback: function (args, certInfo, cb) { sniRegisterCallback: function (args, certInfo, cb) {
var allowedDomains = conf.domains; // require('../tests/config').allowedDomains; var allowedDomains = conf.domains; // require('../tests/config').allowedDomains;

View File

@ -5,11 +5,15 @@
var PromiseA = require('bluebird'); var PromiseA = require('bluebird');
var crypto = require('crypto'); var crypto = require('crypto');
var tls = require('tls'); var tls = require('tls');
var path = require('path');
var LE = module.exports; var LE = module.exports;
LE.liveServer = "https://acme-v01.api.letsencrypt.org/directory"; LE.liveServer = "https://acme-v01.api.letsencrypt.org/directory";
LE.stagingServer = "https://acme-staging.api.letsencrypt.org/directory"; LE.stagingServer = "https://acme-staging.api.letsencrypt.org/directory";
LE.configDir = "/etc/letsencrypt/";
LE.logsDir = "/var/log/letsencrypt/";
LE.workDir = "/var/lib/letsencrypt/";
LE.merge = function merge(defaults, args) { LE.merge = function merge(defaults, args) {
var copy = {}; var copy = {};
@ -25,6 +29,18 @@ LE.merge = function merge(defaults, args) {
}; };
LE.create = function (backend, defaults, handlers) { LE.create = function (backend, defaults, handlers) {
if ('function' === typeof backend.create) {
backend.create(defaults, handlers);
}
else if ('string' === typeof backend) {
// TODO I'll probably regret this
// I don't like dynamic requires because they cause build / minification issues.
backend = require(path.join('backends', backend)).create(defaults, handlers);
}
else {
// ignore
// this backend was created the v1.0.0 way
}
if (!handlers) { handlers = {}; } if (!handlers) { handlers = {}; }
if (!handlers.lifetime) { handlers.lifetime = 90 * 24 * 60 * 60 * 1000; } if (!handlers.lifetime) { handlers.lifetime = 90 * 24 * 60 * 60 * 1000; }
if (!handlers.renewWithin) { handlers.renewWithin = 3 * 24 * 60 * 60 * 1000; } if (!handlers.renewWithin) { handlers.renewWithin = 3 * 24 * 60 * 60 * 1000; }

View File

@ -33,9 +33,16 @@
"express": "^4.13.3", "express": "^4.13.3",
"localhost.daplie.com-certificates": "^1.1.2" "localhost.daplie.com-certificates": "^1.1.2"
}, },
"optionalDependencies": {
"letsencrypt-python": "^1.0.3",
"letsencrypt-forge": "file:letsencrypt-forge",
"letsencrypt-ursa": "file:letsencrypt-ursa",
"node-forge": "^0.6.38",
"ursa": "^0.9.1"
"letiny": "0.0.4-beta",
},
"dependencies": { "dependencies": {
"bluebird": "^3.0.6", "bluebird": "^3.0.6",
"letsencrypt-python": "^1.0.3", "serve-static": "^1.10.0",
"serve-static": "^1.10.0"
} }
} }