Create certificate via Let's Encrypt
To create a certificate through Let's Encrypt, a free and automated Certificate Authority (CA), follow these steps. Let's Encrypt provides SSL/TLS certificates for securing websites and supports automation through tools like Certbot.
Step 1: Prerequisites
Domain Name: Ensure you have a registered domain name (e.g.,
example.com
) pointing to your server's IP address.Server: You need a web server (e.g., Apache, Nginx) running on a server with a public IP address.
Root Access: Access to the server with sudo or root privileges.
Port 80 Open: Ensure HTTP (port 80) is open for Let's Encrypt to perform domain validation.
Step 2: Install Certbot
Certbot is the official Let's Encrypt client that automates the process of obtaining and renewing certificates.
On Debian/Ubuntu:
On CentOS/RHEL:
Step 3: Obtain a Certificate
You can obtain a certificate automatically or manually, depending on your setup.
Automatic Certificate Installation
For supported web servers like Apache or Nginx, Certbot can configure the server automatically.
Example for Nginx:
Example for Apache:
Certbot will:
Detect your web server configuration.
Prompt you to choose a domain name from the list of virtual hosts.
Obtain and install the certificate automatically.
Manual Certificate Installation
If your web server is custom or unsupported, use the standalone method.
Command:
certonly
: Obtain the certificate without modifying the server configuration.--standalone
: Certbot will run its temporary web server for validation.-d
: Specify domain names for the certificate.
The certificate files will be saved to /etc/letsencrypt/live/example.com/
.
Step 4: Test Your Certificate
Verify that the certificate is working by accessing your website via HTTPS:
You can also test your certificate using SSL Labs: SSL Labs Test
Step 5: Automate Renewal
Let's Encrypt certificates are valid for 90 days. Certbot sets up automatic renewal by default via a systemd timer.
To check the timer:
You can test renewal manually:
Step 6: Common Commands
List Certificates:
sudo certbot certificatesRevoke a Certificate:
sudo certbot revoke --cert-path /etc/letsencrypt/live/example.com/cert.pemDelete a Certificate:
sudo certbot delete --cert-name example.com
Example Scenarios
Example 1: Single Domain with Nginx
Example 2: Multiple Subdomains
Example 3: Standalone with Wildcard Domain
Wildcard certificates require DNS validation:
You will need to add a DNS TXT record for _acme-challenge.example.com
as instructed during the process.
Troubleshooting
Port 80 Blocked: Ensure no firewall or ISP restrictions on HTTP.
sudo ufw allow 80 sudo ufw allow 443Certificate Not Loading: Check web server configuration for HTTPS and restart the service:
sudo systemctl restart nginxDomain Validation Errors: Ensure the domain's DNS records are correctly pointing to the server.
Additional Resources
Let's Encrypt Documentation: https://letsencrypt.org/docs/
Certbot Website: https://certbot.eff.org/
By following these steps, you can easily obtain and manage Let's Encrypt certificates for your website.