Sub topic 3
How Let's Encrypt and ACME Issue Certificates
Assume you are comfortable with a Linux shell, sudo, DNS records, HTTP, and systemd. You also need a registered domain that you control and a server reachable from the Internet.
The ACME model
Let's Encrypt is a certificate authority (CA). It issues X.509 certificates that browsers trust. The Automatic Certificate Management Environment (ACME) protocol defines how a client requests a certificate and proves control of the requested domain.
Certbot is an ACME client. It communicates with the Let's Encrypt ACME server, completes a challenge, downloads the certificate, and stores the related files.
The process has these main stages:
- Certbot creates or uses an ACME account.
- Certbot requests a certificate for one or more domain names.
- Let's Encrypt creates an authorization for each name.
- Certbot completes a challenge that proves domain control.
- Let's Encrypt validates the challenge.
- The client submits a certificate signing request (CSR).
- Let's Encrypt signs and returns the certificate.
The certificate proves that the CA validated control of the names. It does not prove that the site owner is trustworthy or that the application itself is secure.
Domain validation challenges
A challenge is a value that the ACME server asks you to publish in a location that only someone controlling the domain should normally be able to change.
| Challenge | Where the proof appears | Common use |
|---|---|---|
| HTTP-01 | An HTTP URL under `/.well-known/acme-challenge/` | A web server with port 80 reachable |
| DNS-01 | A DNS TXT record under `_acme-challenge` | Wildcard certificates or servers without public HTTP |
| TLS-ALPN-01 | A special TLS response on port 443 | Specialized TLS termination setups |
HTTP-01 is usually simplest for an nginx server. The ACME server makes an HTTP request to the domain, and Certbot temporarily serves the expected token. Port 80 must be publicly reachable, even if normal visitors are later redirected to HTTPS.
DNS-01 requires a TXT record containing a token. Because DNS proves control separately from the web server, this method can issue wildcard certificates such as *.example.com.
TLS-ALPN-01 uses the TLS Application-Layer Protocol Negotiation extension. It is useful when a service can control port 443 directly, but it is less common in ordinary nginx deployments.
Test with the staging environment
Let's Encrypt provides a staging environment with untrusted test certificates. Use it while correcting DNS, firewall, nginx, or challenge configuration. Staging avoids consuming production issuance limits, but browsers will not trust the resulting certificate.
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot certonly --nginx --staging \
-d example.com -d www.example.comIf validation succeeds, repeat the request without --staging:
sudo certbot certonly --nginx \
-d example.com -d www.example.comCertbot may ask for an email address and agreement to the subscriber terms. Keep the domain names consistent with the DNS records and nginx server_name values.
Exercise
Why should you use Let's Encrypt staging before requesting a production certificate?
Show answer
Staging lets you test domain validation and server configuration without using production issuance limits, although its certificates are not trusted by normal browsers.