This commit is contained in:
AJ ONeal 2016-08-11 00:58:14 -04:00
parent f36966a0d3
commit 88c8b812a2
2 changed files with 33 additions and 6 deletions

View File

@ -2,10 +2,14 @@
module.exports.create = function (opts) {
opts.workerSniCallback = require('le-sni-auto').create({
getCertificates: function (domain, certs, cb) {
notBefore: opts.notBefore || (10 * 24 * 60 * 60 * 1000)
, notAfter: opts.notAfter || (5 * 24 * 60 * 60 * 1000)
, getCertificates: function (domain, certs, cb) {
opts.approveDomains(domain, certs, function (err, certs) {
process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] } certs: certs });
process.send({ type: 'LE_REQUEST', domain: domain, options: { domains: [domain] }, certs: certs });
process.on('message', function (msg) {
if (msg.domain === domain) {
@ -16,5 +20,24 @@ module.exports.create = function (opts) {
}
}).sniCallback;
opts.httpsOptions = require('localhost.daplie.com-certificates').merge({ SNICallback: opts.workerSniCallback });
opts.challenge = {
get: opts.getChallenge
|| (opts.challenge && opts.challenge.get)
|| require('le-challenge-fs').create({ webrootPath: opts.webrootPath }).get
};
// opts.challenge.get, opts.acmeChallengePrefix
opts.middleware = require('letsencrypt/lib/middleware').create(opts);
return opts;
};

View File

@ -21,7 +21,7 @@ function runMaster() {
//
// Since we implement it in the worker (below) in this example
// we'll give it an immediate approval here in the master
var results = { options: { domains: [domain] }, certs: certs };
var results = { domain: domain, options: { domains: [domain] }, certs: certs };
cb(null, results);
}
});
@ -53,7 +53,7 @@ function runWorker() {
, approveDomains: function (domain, certs, cb) {
// opts = { domains, email, agreeTos, tosUrl }
// certs = { subject, altnames, expiresAt, issuedAt }
var results = { options: { domains: [domain] }, certs: certs };
var results = { domain: domain, options: { domains: [domain] }, certs: certs };
@ -81,8 +81,12 @@ function runWorker() {
res.end("Hello, World!");
}
var plainServer = require('http').createServer(worker.handleAcmeOrRedirectToHttps());
var server = require('https').createServer(worker.httpsOptions, worker.handleAcmeOrUse(app));
// worker.handleAcmeOrRedirectToHttps()
// worker.handleAcmeOrUse(app)
var redirectHttps = require('redirect-https')();
var plainServer = require('http').createServer(worker.middleware(redirectHttps));
var server = require('https').createServer(worker.httpsOptions, worker.middleware(app));
plainServer.listen(80);
server.listen(443);
}