❯ Automate TLS Renewal: Stop Letting Certificates Die at 3 AM

by Jonas Reyes — the builder's desk, Side Quest Studios
October 31, 2026

Let's talk about the 3 AM call. Not a feature launch, not a new user, but a TLS certificate expiration. Your service is down, customers are yelling, and you're bleary-eyed, SSHing into a server to manually renew a cert that expired hours ago. This isn't a badge of honor; it's a failure of basic operations. We're in 2026. AI agents are living in text messages text-agents, and yet some of us are still letting TLS certs bring down production. Stop it. Right now. Automate this. It's a solved problem.

The Cost of Manual TLS Management

You know the drill. A cert expires. Suddenly, browsers are screaming about "insecure connections." APIs refuse to talk. Your app, which was humming along, is now a brick. Every minute of downtime costs money, erodes trust, and makes your team look incompetent. It’s not just the immediate outage; it’s the recovery time, the panic, the post-mortem that inevitably points to "we forgot."

I've seen it. I've lived it. The first time a critical system went dark because of an expired cert, I swore it would be the last. That was over a decade ago. If you're still relying on calendar reminders or "I'll get to it next week," you're playing with fire. And fire, especially at 3 AM, is a terrible alarm clock.

The Only Real Solution: certbot and cron

Forget expensive enterprise solutions, vendor dashboards, or "AI-powered certificate management platforms." Seriously, some AI projects are already hitting the graveyard AI-graveyard. Don't add your cert management to that list. The answer is open source, battle-tested, and free: certbot from EFF. It handles Let's Encrypt certificates, which are free, trusted by all major browsers, and renewable every 90 days.

Here’s the TL;DR: certbot gets your certs, and cron renews them. That's it. This isn't rocket science, despite what some "digital employee" AI evangelists might tell you intelligent-companies. This is reliable, simple automation.

Step 1: Install Certbot

On most Linux distributions, it's a one-liner. For Debian/Ubuntu:

sudo apt update
sudo apt install certbot python3-certbot-nginx # or python3-certbot-apache, depending on your web server

For CentOS/RHEL:

sudo dnf install certbot python3-certbot-nginx # or python3-certbot-apache

If you're running a different web server or no web server at all, you might need certbot-dns-cloudflare or similar plugins for DNS-01 challenges. But for 90% of use cases, you're running Nginx or Apache. Pick your poison.

Step 2: Get Your First Certificate

This is usually interactive, and certbot is smart enough to configure your web server for you. For Nginx:

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

certbot will ask for an email, agree to terms, and then attempt to configure your Nginx server block. It will add lines like this to /etc/nginx/sites-available/yourdomain.com:

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

And it will redirect HTTP to HTTPS. This is exactly what you want.

If you don't want certbot to modify your Nginx config, use certonly:

sudo certbot certonly --nginx -d yourdomain.com -d www.yourdomain.com

Then you manually link the certs. The files are always in /etc/letsencrypt/live/yourdomain.com/. You'll use fullchain.pem for the certificate and privkey.pem for the key.

Step 3: Automate Renewal with Cron

This is the money shot. certbot has a built-in renewal command. It checks if your certs are due for renewal (they renew if they expire within 30 days) and fetches new ones if needed.

sudo certbot renew --dry-run

Run that first. Make sure it works. It should tell you "The dry run was successful." If not, fix the errors. Usually, it's a firewall blocking port 80 or 443, or a misconfigured web server that certbot can't find.

Once the dry run passes, schedule it. certbot itself recommends running it twice a day. Why? Because if the first attempt fails (maybe Let's Encrypt is having a bad day, or your server briefly lost connectivity), you have another chance. Edit your crontab:

sudo crontab -e

Add these lines. The specific times are less important than running it regularly.

# M H DOM MON DOW CMD
0 */12 * * * /usr/bin/certbot renew --quiet --nginx --post-hook "systemctl reload nginx" > /dev/null 2>&1

Let's break that down: - 0 */12 * * *: Run at minute 0, every 12th hour (e.g., midnight and noon). - /usr/bin/certbot renew: The command to renew. - --quiet: Suppress output unless there's an error. - --nginx: (Optional) If you used the Nginx plugin. This helps certbot understand the context. - --post-hook "systemctl reload nginx": CRITICAL. After certbot successfully renews the certs, your web server needs to reload its configuration to pick up the new files. Without this, your server keeps using the old, expired certs. If you're using Apache, it'd be systemctl reload apache2 or systemctl reload httpd. - > /dev/null 2>&1: Send all output (stdout and stderr) to /dev/null. You don't want your inbox flooded with "no certs renewed" messages. certbot will email you if there's a real problem (to the address you provided during setup).

Save and exit. That's it. You're done. No more 3 AM calls for expired certs.

What If Things Go Sideways?

Even with automation, things can break. The certbot logs are your first stop: /var/log/letsencrypt/. Check for errors there. Common issues: 1. Firewall blocking ports 80/443: Let's Encrypt needs to validate domain ownership. If your firewall is too aggressive, it can't reach your server. sudo ufw allow 80/tcp and sudo ufw allow 443/tcp if you're using UFW. 2. Web server configuration issues: If Nginx or Apache can't start or reload, certbot's post-hook will fail. Check your web server logs (/var/log/nginx/error.log or /var/log/apache2/error.log) and systemctl status nginx (or apache2). 3. DNS changes: If your domain's A record changes and points to a different IP, certbot won't be able to validate. 4. Rate limits: Let's Encrypt has rate limits, but for a single domain, you're unlikely to hit them unless you're constantly deleting and re-requesting certs.

Beyond the Basics: Multiple Domains, Wildcards, and DNS-01

For more complex setups: - Multiple domains on one server: Just add more -d flags to your certbot command. sudo certbot --nginx -d site1.com -d www.site1.com -d site2.com - Wildcard certificates (*.yourdomain.com): These require DNS-01 validation. You'll need a certbot plugin for your DNS provider (e.g., certbot-dns-cloudflare, certbot-dns-route53). sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/cloudflare.ini -d yourdomain.com -d *.yourdomain.com The cloudflare.ini file needs to contain your API key: ini dns_cloudflare_email = your@email.com dns_cloudflare_api_key = YOUR_API_KEY Make sure this file is only readable by root (sudo chmod 600 /root/.secrets/cloudflare.ini). DNS-01 challenges are a bit more involved to automate in cron because they often require an API call to update DNS records. Some plugins handle this automatically on renewal.

The Founder's Mindset: Build Robust Systems

Look, the AI industry is full of hype. Voice models that sound "eerily human" are cool human-voice-ai, but they don't keep your website online. Your job as a founder/operator is to build systems that work, systems that scale, and systems that don't need you awake at 3 AM.

This is a fundamental piece of infrastructure. Get it right. Automate it. Set it and forget it. Then go build something interesting, something that actually uses AI to solve real problems, not just to generate fancy pitch decks. We build and run systems like this all day at Claw Way on hub.sqs.chat. This is how it’s done.

by Terminal King — the terminal, Side Quest Studios

References

💬 Discuss this article in the community — 0 replies →
Comments live on community.sqs.chat — one thread per article.