Last updated
SSL / TLS
Let's Encrypt SSL
Obtain and auto-renew free SSL certificates from Let’s Encrypt using Certbot.
Contents
- Apache: Let's Encrypt on Apache (Ubuntu 24.04 and 22.04): Free HTTPS
- Wildcard (DNS challenge): Let's Encrypt Wildcard Certificate With the DNS Challenge
- Renewal troubleshooting: Let's Encrypt Renewal Failing? Find and Fix the Cause
- Multiple domains (SAN): Let's Encrypt for Multiple Domains: One Certificate, Many Names
- Move to a new server: Move Let's Encrypt Certificates to a New Server
- Standalone, mail servers: Let's Encrypt Without a Web Server: Standalone Mode for Mail and Other Services
- Revoke and delete: Revoke or Delete a Let's Encrypt Certificate (Certbot)
- Key type: ECDSA or RSA: Let's Encrypt Key Type: Check and Switch Between ECDSA and RSA
Install Certbot
# Ubuntu with NGINX
sudo apt install -y certbot python3-certbot-nginx
# Ubuntu with Apache
sudo apt install -y certbot python3-certbot-apache
# Or use snap (always latest version)
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
Issue a Certificate
# NGINX, auto-configure HTTPS
sudo certbot --nginx -d example.com -d www.example.com
# Apache, auto-configure HTTPS
sudo certbot --apache -d example.com -d www.example.com
# Standalone (no web server running)
sudo certbot certonly --standalone -d example.com
# Webroot (web server must be running)
sudo certbot certonly --webroot -w /var/www/html -d example.com
Wildcard Certificates
Wildcard certs (*.example.com) require DNS challenge. Requires DNS API access.
sudo certbot certonly --manual --preferred-challenges dns -d "*.example.com" -d "example.com"
# Certbot will prompt you to add a TXT record:
# _acme-challenge.example.com TXT "VERIFICATION_VALUE"
Auto-Renewal
# Certbot installs a systemd timer automatically. Verify it's active:
sudo systemctl status certbot.timer
# Test renewal without actually renewing
sudo certbot renew --dry-run
# Force renewal
sudo certbot renew --force-renewal
Certificate File Locations
# Certificates are stored in:
/etc/letsencrypt/live/example.com/
# Key files:
cert.pem # domain certificate
privkey.pem # private key
chain.pem # intermediate CA chain
fullchain.pem # cert + chain (use this in most configs)
NGINX SSL Configuration
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
}
FAQ
Is Let's Encrypt free?
Yes. It is a free, nonprofit certificate authority trusted by all major browsers.
How long do Let's Encrypt certificates last?
90 days. Certbot renews them automatically about 30 days before they expire; test with sudo certbot renew –dry-run.