ACME TLS
Forked from Greenlock, a Root v2.6.8. Greenlock is a trademark of AJ ONeal.
How it differs:
- Email address is not required.
- No telemetry or tracking. (TODO)
- ACME v2 only. (TODO)
Why the fork?
Greenlock introduced a privacy-violating requirement for obtaining a Let’s Encrypt TLS certificate that goes above and beyond what is mandated by Let’s Encrypt. When you register for a Let’s Encrypt TLS certificate, you do not need to provide your email address. This is A Good Thing™. Greenlock makes the email address required. This fork removes this artificial requirement.
Usage
If you want a simple-to-use Small Tech personal web server that automatically provisions both locally-trusted TLS certificates using nodecert and globally-trusted ones using this module, see HTTPS Server
See the relevant method in HTTPS Server for an example of real-world usage.
Example
Here is an example based on HTTPS Server that sets up an Express server. The first time you hit it, TLS certificates will be automatically provisioned for you.
Prerequisites:
mkdir example && cd example
npm init --yes
npm i express redirect-https @ind.ie/acme-tls
touch index.js && $EDITOR index.js
If you’re on Linux, you will need to also run this (or the equivalent for your distribution if you don’t have the apt package manager) to bind to port 443 for TLS as we’re still engaged in mainframe-era privileged port security theatre on that platform:
sudo apt install libcap2-bin
setcap 'cap_net_bind_service=+ep' $(which node)
Code:
const os = require('os')
const Express = require('express')
const AcmeTLS = require('@ind.ie/acme-tls')
const redirectHTTPS = require('redirect-https')
const hostname = os.hostname()
const acmeTLS = AcmeTLS.create({
server: 'https://acme-v02.api.letsencrypt.org/directory',
version: 'draft-11',
configDir: `~/.nodecert/${hostname}/`,
approvedDomains: [hostname, `www.${hostname}`],
agreeTos: true,
telemetry: false,
communityMember: false
})
const httpsRedirectionMiddleware = redirectHTTPS()
const httpServer = http.createServer(acmeTLS.middleware(httpsRedirectionMiddleware))
httpServer.listen(80, () => {
console.log(' 👉 HTTP → HTTPS redirection active.')
})
const options = {}
Object.assign(options, acmeTLS.tlsOptions)
const app = Express()
app.get('/', (request, response) => {
response.writeHeader(200, {'Content-Type': 'text/html'})
response.end('<!doctype html><html lang=\'en\'><head><meta charset=\'utf-8\'/><title>Hello, world!</title><style>body{background-color: white; font-family: sans-serif;}</style></head><body><h1>Hello, world!</h1></body></html>')
})
const server = https.createServer(options, app)
server.listen(443, () => {
console.log(' 🎉 Server running on port 443.')
})
License
All commits later than and including fccf48b are licensed under AGPLv3 or later. All commits before and including ff000c4 licensed under MPL 2.0.