HTTP, TLS & Web Performance

Let's Encrypt and Automated Certificates With ACME

Understand how ACME proves you control a domain, choose the right challenge type, set up automatic renewal with Certbot and avoid common failures.

Key takeaways

  • ACME, standardized as RFC 8555, automates requesting, validating and renewing certificates.
  • The HTTP-01 challenge needs your site reachable on port 80, while DNS-01 needs the ability to create a DNS record.
  • Wildcard certificates from Let's Encrypt require the DNS-01 challenge.
  • Certificates are deliberately short-lived, so tested automatic renewal is part of the setup.
  • Use the staging environment or a dry run while experimenting, to avoid hitting rate limits.

Let's Encrypt is a nonprofit certificate authority that issues free, domain-validated certificates through an automated protocol called ACME. A program on your server asks for a certificate, proves it controls the domain, installs the result and renews it later, usually without you touching it again.

If your host or platform already manages HTTPS, you may be using it or a similar service without knowing. If you run your own server, this guide shows how the pieces fit and how to set them up safely.

How ACME works

ACME stands for Automatic Certificate Management Environment. It is a protocol between an ACME client, software you run, and the CA's ACME server.

The client creates an account key that identifies it. To get a certificate, it submits an order listing domain names. The CA replies with challenges, tasks that only someone controlling those names could complete. Once validation passes, the client sends a certificate signing request and downloads the signed certificate. Your server's private key is generated locally and never sent to the CA.

An ACME order with an HTTP challenge
ACME client Certificate authority Order a certificate for example.com 1 Here is a challenge token 2 Token is published, please check 3 Fetches the token over port 80 4 From its own validation servers Send certificate signing request 5 Signed certificate and chain 6 ACME client Certificate authority Order a certificate for example.com 1 Here is a challenge token 2 Token is published, please check 3 Fetches the token over port 80 4 From its own validation servers Send certificate signing request 5 Signed certificate and chain 6

The protocol is open, so other authorities offer ACME too. A client that supports it can usually switch between them by changing a directory address and, for some providers, adding account credentials.

The three challenge types

HTTP-01

The client places a file under http://example.com/.well-known/acme-challenge/ containing a value derived from the token and your account key. The CA fetches it on port 80. Redirects to HTTPS are followed.

It is the easiest option for an ordinary public web server. It can't issue wildcards, and it fails if port 80 is blocked or the name points elsewhere.

DNS-01

The client creates a TXT record at _acme-challenge.example.com. The CA looks it up in DNS. This works for servers that aren't reachable from the internet and is required for wildcard names.

Automating it means giving your ACME client permission to edit DNS. Use a narrowly scoped API token where your provider offers one, because a credential that can change your whole zone is very powerful. Some setups point _acme-challenge with a CNAME to a separate zone that holds nothing else.

TLS-ALPN-01

Defined in RFC 8737, this proves control through a special TLS handshake on port 443. It suits software that terminates TLS itself, such as certain web servers and proxies.

Picking a challenge
Do you need a wildcard certificate? YES Use DNS-01 with an automated, limited DNS credential. 1 NO Is the server unreachable from the public internet? YES Use DNS-01 for a public name you control. 2 NO Can the CA reach your web server on port 80? YES Use HTTP-01, the simplest route. 3 NO Does your server software handle TLS-ALPN-01? YES Use it on port 443. 4 NO Fall back to DNS-01 It works wherever you can edit the domain's records. Do you need a wildcard certificate? 1 IF YES Use DNS-01 with an automated, limited DNS credential. NO Is the server unreachable from the public internet? 2 IF YES Use DNS-01 for a public name you control. NO Can the CA reach your web server on port 80? 3 IF YES Use HTTP-01, the simplest route. NO Does your server software handle TLS-ALPN-01? 4 IF YES Use it on port 443. NO Fall back to DNS-01 It works wherever you can edit the domain's records.

Setting it up with Certbot

Certbot is a widely used ACME client. Install it using the method its documentation recommends for your operating system. Before starting, make sure your DNS records point at the server and that the firewall allows ports 80 and 443.

For nginx, with the plugin installed:

sudo certbot --nginx -d example.com -d www.example.com

Apache uses --apache instead. If you'd rather edit server configuration yourself, request only the certificate and point Certbot at your web root:

sudo certbot certonly --webroot -w /var/www/html -d example.com -d www.example.com

On typical Linux installs, files appear under /etc/letsencrypt/live/example.com/. Point the server at fullchain.pem for the certificate chain and privkey.pem for the key. Using the full chain avoids missing-intermediate errors.

Some web servers and proxies, Caddy among them, have ACME built in and need only a domain name in their configuration. Many hosting control panels offer a checkbox that does the same.

Renewal

Let's Encrypt certificates have historically lasted 90 days, and the organization has announced a move toward shorter lifetimes. Check its documentation for the current figures. Either way, manual renewal is a recipe for an outage.

Most Certbot packages install a scheduled task or systemd timer that runs certbot renew, which only replaces certificates that are close enough to expiry. Verify the whole path:

sudo certbot renew --dry-run
systemctl list-timers | grep -i certbot

A renewed file on disk does nothing until the server reloads it. When you use certonly, add a deploy hook:

sudo certbot renew --deploy-hook "systemctl reload nginx"

Newer ACME features also let a CA suggest when a client should renew, which helps if certificates ever need early replacement. Keeping your client updated is how you get such improvements.

The automated certificate lifecycle
Monitor An outside check confirms the expiry date Reload Server starts using the new files Check A scheduled job reviews certificate ages Validate Complete a fresh domain challenge if needed Issue Download the new certificate and chain 1 2 3 4 5 Check A scheduled job reviews certificate ages 1 Validate Complete a fresh domain challenge if needed 2 Issue Download the new certificate and chain 3 Reload Server starts using the new files 4 Monitor An outside check confirms the expiry date 5

Rate limits and staging

Let's Encrypt limits how many certificates and failed validations can occur in given periods, to keep the free service healthy. The exact numbers change, so consult its published limits.

While testing, add --dry-run or --test-cert so requests go to the staging environment. Staging certificates aren't trusted by browsers, which is expected. If a setup keeps failing, fix the cause before retrying; a loop of failed attempts can lock you out for a while.

Certificates across several servers

One server with one client is simple. Several servers behind a load balancer need a plan, because an HTTP challenge may land on a machine that doesn't have the token.

Common arrangements include:

  • Terminate TLS at the balancer or proxy. Only that layer needs certificates, and many managed services handle issuance for you.
  • Route challenge requests to one machine. Every node forwards /.well-known/acme-challenge/ to a designated renewal host, which then distributes the new files securely.
  • Use DNS-01 centrally. One system obtains certificates without needing inbound web traffic, then deploys them to the others.

Whichever you pick, copy private keys only over encrypted, authenticated channels, restrict who can read them, and confirm each node reloaded. Check each server's address individually, since a single forgotten machine produces errors for only some visitors, which is hard to diagnose.

Looking after the setup

Run sudo certbot certificates to list what Certbot manages, with names, expiry dates and file paths. Remove certificates for sites you've retired using certbot delete, after taking them out of the server configuration, so failed renewals don't clutter your logs and hide real problems.

When you move a site, set up issuance on the new server before changing DNS if you can, for instance with a DNS challenge. Otherwise there may be a gap between the name pointing at the new machine and that machine having a valid certificate. If your site sends HSTS headers, visitors can't click past that gap.

Keep the client up to date through your package system. Certificate authorities change chains, lifetimes and protocol features over time, and current client software absorbs most of those changes without any effort from you. Avoid hard-coding a particular intermediate certificate anywhere, since authorities rotate them.

Finally, write down how the setup works: which client runs on which machine, which challenge it uses, where credentials live and who receives alerts. Automation that has run quietly for a year is easy to forget, and the person fixing it may not be the one who built it.

What can go wrong

  • DNS points elsewhere. The CA validates whatever the public name resolves to.
  • A stale AAAA record. If an IPv6 address is published but doesn't serve your site, validation may fail. Fix or remove it.
  • Port 80 closed. HTTP-01 needs it even if the site is otherwise HTTPS only.
  • Redirects or application routing intercepting the .well-known path.
  • CAA records that don't permit the authority. See CAA records.
  • DNS propagation delay between creating a TXT record and the CA querying it.
  • Hand-added DNS records. A manual DNS-01 certificate can't renew by itself.
  • Containers without persistent storage, which request a new certificate at every restart and exhaust limits.

Read the error message closely; ACME errors usually state which URL or record was checked and what came back. Client logs, often under /var/log/letsencrypt/ for Certbot, have the detail.

Limits of what you get

ACME authorities such as Let's Encrypt issue domain-validated certificates. They don't verify organization identity; if you need that, compare validation levels. The encryption is equally strong.

Every issued certificate is recorded in public transparency logs, so hostnames in certificates are discoverable. Don't put secrets in subdomain names. For many internal names, a wildcard or a private CA reveals less.

Automation also shifts your risk. Protect the account key and any DNS credentials, and monitor expiry from outside the server, so a silently broken timer gets noticed while there is still time to act.

Common questions

Can I get a certificate for an IP address or a private name?

Publicly trusted authorities can't certify private names like server.local or private addresses. Certificates for public IP addresses exist at some CAs under specific conditions. For internal use, run a private CA.

Do I need to open port 80 permanently?

If you rely on HTTP-01, it must be reachable at renewal time. Leaving it open with a redirect to HTTPS is a normal arrangement.

Is it really free for commercial sites?

Let's Encrypt doesn't charge for certificates, including for businesses. You still spend time on setup and monitoring.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in HTTP, TLS & Web Performance →

Latest news on this topic