Speed up SSL issuance
GoGetSSL® offers fastest issuance of SSL due to use of LEI code and API automation. Legal Entity Identifier (LEI) is a global identity code, just like DUNS. Learn how LEI works.
Automating SSL/TLS for your Node.js application using an ACME SSL certificate keeps your site secure without manual renewals. This guide uses acme.sh client with External Account Binding (EAB) and shows how to configure a Node.js app with PM2, issue, install, auto-renew, and verify certificates. Example commands use placeholders — replace them with your actual values.
Install the acme.sh script to handle ACME SSL certificate issuance, installation, and renewal.
curl https://get.acme.sh | sh
source ~/.bashrc
acme.sh --version

Register your ACME client with your Certificate Authority (CA) using EAB credentials:
acme.sh --register-account \
--server SERVER \
--eab-kid EAB_KID \
--eab-hmac-key EAB_HMAC_KEY \
--accountemail you@example.com
Replace these placeholders with your own values:

Follow these sub-steps to ensure your Node.js app runs continuously and restarts automatically on server reboot using PM2.
sudo npm install -g pm2
pm2 --version

pm2 start server.js --name yourapp-site
Run only ONE of the following commands based on how PM2 is running on your server. Root (sudo) access is required.
### If PM2 is running as root (most cloud servers):
pm2 startup systemd
Or
### If PM2 is running as a normal user:
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u <user> --hp /home/<user>
### Save the current PM2 process list
pm2 save
### Optional: Remove startup configuration (if reset is needed)
pm2 unstartup systemd
pm2 status

Issue the certificate using the Node.js app’s static folder (webroot):
acme.sh --issue \
-d yourdomain.com \
-w /path/to/project/public \
--server < ACME_SERVER_URL >
Replace these placeholders with your own values:

Follow these sub-steps to install the SSL certificate into your Node.js app and configure PM2 for automatic reload:
Create a directory to store your SSL certificate and key files:
mkdir -p ~/yourapp-site/cert
acme.sh --install-cert -d yourdomain.com \
--key-file /path/to/ssl/yourdomain.key \
--fullchain-file /path/to/ssl/yourdomain.crt \
--reloadcmd "pm2 restart yourapp-site"
Replace these placeholders with your own values:
Set ownership and permissions to protect your private key and certificate files. By default, private keys are restricted to root for security, ensuring HTTPS works correctly if your Node.js/PM2 process runs as root.
sudo chown root:root /path/to/ssl/*
sudo chmod 600 /path/to/ssl/yourdomain.key
sudo chmod 644 /path/to/ssl/yourdomain.crt
After each renewal, acme.sh will reuse these paths and reload your Node.js app via PM2 automatically.

To enable HTTPS, you’ll need to update your Node.js server.js file. Follow these sub-steps in order:
Add the following require statements to the top of server.js:
const express = require('express');
const fs = require('fs');
const https = require('https');
const http = require('http');
const path = require('path');
const app = express();
// Serve static files (public folder)
app.use(express.static(path.join(__dirname, 'public')));
// Serve ACME challenge files explicitly (for certificate renewal)
app.use(
'/.well-known/acme-challenge',
express.static(path.join(__dirname, 'public', '.well-known', 'acme-challenge'), { dotfiles: 'allow' })
);
app.get('/', (req, res) => {
res.send('<h1>Hello from yourdomain.com (HTTPS enabled)</h1>');
});
http.createServer((req, res) => {
res.writeHead(301, { Location: 'https://' + req.headers.host + req.url });
res.end();
}).listen(80, () => {
console.log('HTTP server running on port 80 (redirecting to HTTPS)');
});
https
.createServer(
{
key: fs.readFileSync('/path/to/ssl/yourdomain.key'),
cert: fs.readFileSync('/path/to/ssl/yourdomain.crt')
},
app
)
.listen(443, () => {
console.log('Server running securely on https://yourdomain.com');
});
Replace these placeholders with your own values:
After updating server.js, restart your Node.js application:
# Standard restart (use this normally)
pm2 restart yourapp-site

Required when switching from HTTP → HTTPS (prevents port conflicts). If your previous server.js used HTTP on port 80 and you replaced it with HTTPS configuration, PM2 may still hold the old process in memory.
To avoid stale HTTP bindings and ensure HTTPS loads correctly, run:
pm2 stop all
pm2 delete all
pkill node
# Start fresh with HTTPS
pm2 start server.js --name yourapp-site
pm2 save

Note for Non-Root Deployment. Port 443 typically requires root privileges. If your Node.js/PM2 process runs as a non-root user, you have two options:
1. Run the server on a higher port (e.g., 8443) and use a reverse proxy (like NGINX) to forward HTTPS traffic.
2. Use `setcap` to allow Node.js to bind to port 443.
Additionally, ensure the SSL key file is readable by the non-root process:
sudo chown <user>:<group> /path/to/ssl/yourdomain.key
sudo chmod 600 /path/to/ssl/yourdomain.key
The certificate file (.crt) can remain world-readable (chmod 644).
This ensures HTTPS works correctly without running your application as root, maintaining security best practices.
Visit https://yourdomain.com and confirm:
Site loads over HTTPS
Certificate is valid and matches your domain
crontab -l
acme.sh --renew -d yourdomain.com --force
Replace these placeholders with your own values:

These steps are not required for most installations but are helpful if you encounter issues. You may also contact our support team for more questions.
Create the .well-known/acme-challenge directory and confirm that the test file is accessible:
mkdir -p ~/yourapp-site/public/.well-known/acme-challenge
echo "Welcome test" > ~/yourapp-site/public/.well-known/acme-challenge/testfile
curl http://yourdomain.com/.well-known/acme-challenge/testfile
Replace these placeholders with your own values:

You have successfully::
SSL renewals now run automatically without manual intervention.
Get a Domain Validation SSL certificate within just 5 minutes using our friendly and automated system. No paperwork, callback or company required.
Found a better price? We will match it - guaranteed. Get the best possible price in the World with us. The correct place to save your money.
No more manual installations or expiring certificates: automate your SSL certificates with ACME. Get Started with ACME SSL
Customer satisfaction is our major concern. Get a full refund within 30 days for any purchase of SSL certificates with 100% guarantee.
GoGetSSL® offers fastest issuance of SSL due to use of LEI code and API automation. Legal Entity Identifier (LEI) is a global identity code, just like DUNS. Learn how LEI works.