cleanup
This commit is contained in:
parent
07e118889a
commit
73ed1ad7a9
|
@ -0,0 +1,9 @@
|
|||
moved the tests to the examples folder
|
||||
|
||||
```bash
|
||||
node examples/commandline.js example.com,www.example.com user@example.com agree
|
||||
```
|
||||
|
||||
Try it for yourself.
|
||||
|
||||
Go watch [Let's Encrypt in (exactly) 90 seconds](https://daplie.com/articles/lets-encrypt-in-literally-90-seconds/) and swap out the Caddy instructions with the node instructions.
|
|
@ -1,37 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var config = require('./config');
|
||||
var Letsencrypt = require('../');
|
||||
var leBinPath = '/home/user/.local/share/letsencrypt/bin/letsencrypt';
|
||||
var LEP = require('letsencrypt-python');
|
||||
var lep = LEP.create(leBinPath);
|
||||
|
||||
require('./serve-acme-challenges').create({
|
||||
configDir: config.configDir
|
||||
});
|
||||
|
||||
//var networkInterfaces = require('os').networkInterfaces();
|
||||
//var ipify = require('ipify');
|
||||
|
||||
var le = Letsencrypt.create(
|
||||
lep
|
||||
// set some defaults
|
||||
, { configDir: config.configDir
|
||||
, workDir: config.workDir
|
||||
, logsDir: config.logsDir
|
||||
|
||||
, webroot: true
|
||||
, webrootPath: config.webrootPath
|
||||
|
||||
, server: LEP.stagingServer
|
||||
}
|
||||
, { cacheContextsFor: 1 * 60 * 60 * 1000 // 1 hour
|
||||
, cacheRenewChecksFor: 3 * 24 * 60 * 60 * 1000 // 3 days
|
||||
}
|
||||
);
|
||||
|
||||
le.register({
|
||||
agreeTos: true
|
||||
, domains: ['lds.io']
|
||||
, email: 'coolaj86@gmail.com'
|
||||
});
|
|
@ -1,92 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var https = require('https');
|
||||
var http = require('http');
|
||||
var express = require('express');
|
||||
var app = express();
|
||||
|
||||
module.exports.create = function (opts) {
|
||||
function getSecureContext(domainname, opts, cb) {
|
||||
|
||||
if (!opts) { opts = {}; }
|
||||
|
||||
opts.key = fs.readFileSync(path.join(opts.configDir, 'live', domainname, 'privkey.pem'));
|
||||
opts.cert = fs.readFileSync(path.join(opts.configDir, 'live', domainname, 'cert.pem'));
|
||||
/*
|
||||
opts.ca = fs.readFileSync(path.join(opts.configDir, 'live', domainname, 'chain.pem'), 'ascii')
|
||||
.split('-----END CERTIFICATE-----')
|
||||
.filter(function (ca) {
|
||||
return ca.trim();
|
||||
}).map(function (ca) {
|
||||
return (ca + '-----END CERTIFICATE-----').trim();
|
||||
});
|
||||
*/
|
||||
|
||||
cb(null, require('tls').createSecureContext(opts));
|
||||
}
|
||||
|
||||
|
||||
// log the requests
|
||||
app.use('/', function (req, res, next) {
|
||||
console.log('[' + req.ip + ']', req.method + ' ' + req.headers.host, req.protocol + req.url);
|
||||
next();
|
||||
});
|
||||
// handle static requests to /.well-known/acme-challenge
|
||||
app.use(
|
||||
'/.well-known/acme-challenge'
|
||||
, express.static(opts.webrootPath, { dotfiles: undefined })
|
||||
);
|
||||
|
||||
function serveHttps() {
|
||||
//
|
||||
// SSL Certificates
|
||||
//
|
||||
var server;
|
||||
var localCerts = require('localhost.daplie.com-certificates');
|
||||
var options = {
|
||||
requestCert: false
|
||||
, rejectUnauthorized: true
|
||||
|
||||
// If you need to use SNICallback you should be using io.js >= 1.x (possibly node >= 0.12)
|
||||
, SNICallback: function (domainname, cb) {
|
||||
var secureContext = getSecureContext(domainname);
|
||||
cb(null, secureContext);
|
||||
}
|
||||
// If you need to support HTTP2 this is what you need to work with
|
||||
//, NPNProtocols: ['http/2.0', 'http/1.1', 'http/1.0']
|
||||
//, NPNProtocols: ['http/1.1']
|
||||
, key: localCerts.key
|
||||
, cert: localCerts.cert
|
||||
//, ca: null
|
||||
};
|
||||
|
||||
// Start the tls sni server4
|
||||
server = https.createServer(options);
|
||||
server.on('error', function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
server.on('request', app);
|
||||
server.listen(opts.tlsSni01Port, function () {
|
||||
console.log('[https] Listening', server.address());
|
||||
});
|
||||
}
|
||||
|
||||
function serveHttp() {
|
||||
// Start the http server4
|
||||
var insecureServer = http.createServer();
|
||||
insecureServer.on('error', function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
// note that request handler must be attached *before* and handle comes in
|
||||
insecureServer.on('request', app);
|
||||
insecureServer.listen(opts.http01Port, function () {
|
||||
console.log('[http] Listening', insecureServer.address());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
serveHttps();
|
||||
serveHttp();
|
||||
};
|
|
@ -1,2 +0,0 @@
|
|||
curl http://localhost:80/.well-known/acme-challenge/hello
|
||||
curl https://localhost.daplie.com:5001/.well-known/acme-challenge/hello
|
Loading…
Reference in New Issue