Skip to content

Finally automated SSL for all client subdomains

Web Hosting by marcus_qc 24 replies 3.5K views
9 #1

Hey folks! Super stoked right now

Finally cracked it — automated SSL for all my client subdomains on this cheap RackNerd VPS. No more letsencrypt manual runs, no more expired certs making me look like a chump.

Bash script attached, credentials sanitized (I hope? Changed the API key format at least). Basically loops through cPanel, checks cert expiry, fires acme.sh if under 14 days. Handles wildcards via dns-01 through their API.

Been running clean for 3 months. Clients stopped complaining. Feels good man.

[code]#!/bin/bash
# ssl_autobot.sh - runs via cron daily
# TODO: add notification on failure
API_KEY="dh_live_xxxxxxxxxxxxxxxx"
DOMAIN_LIST="/etc/ssl/domains.txt"
For domain in $(cat $DOMAIN_LIST); do
Expiry=$(echo | openssl s_client -servername $domain -connect $domain:443 2>/dev/null | openssl x509 -noout -dates | grep notAfter | cut -d= -f2)
# ... rest of logic
Done

Anyone want to improve the error handling? I know it's barebones. Gonna add slack webhook eventually.

42U and still growing
5 #2

Or you could just use certbot with proper hooks, how do you say, obviously this is the pinnacle of engineering /s

Clearly sanitizing credentials means changing the prefix from "live_" to "test_" and calling it a day. No wait, you kept the domain list path. Obviously secure.

I am detecting sarcasm in my own post, or no? /s

#3

I would recommend adding a check for empty strings.

Furthermore, you are logging to no destination. Under GDPR, if this processes any personal data of EU citizens — and client subdomains may qualify — you need to consider your logging retention policy. The absence of notification is not merely a technical gap but a compliance consideration.

Neuland. Aber schnell.
#4

I fix one thing, you dont check if acme.sh is installed, this will fail silently, I add check for this, also maybe use lockfile so two instance dont run, happened to me once, cost me rate limit xd

Also "ssl_autobot.sh" is bad name, make it descriptive

POLISH SERVERS. LOUD FANS. GOOD PRICE.
6 #5

SWEET script but HÖSTING on RackNerd? Brave. FIkA break first, then fix your error handling. SERiously though:

- no temp file cleanup
- openssl s_client timeout not set
- your TODO comment about notifications? Been there. Forgot. Expired cert on client site for WEEKS. Umlaut of shame: äwkwärd

#6

Wey this is nice but you forgot the most important part?? The notification!!

I did same thing with CloudCone (https://cloudcone.com) once, everything automated, no alertas when it fails, client calls me angry because their shop shows "not secure" for three days!! Never again!!

Add the slack webhook now wey, not eventually!!

declarative or death
#7

Article 13 flashbacks aside, this raises serious questions about automated certificate management under the eIDAS 2.0 framework currently being harmonized. Your clients rely on these certificates for trust services.

The absence of notification infrastructure constitutes a single point of failure. I would recommend redundant alerting channels — not merely Slack, but also SMS gateway failover — to maintain continuity of the qualified trust service. GDPR Article 32 requires appropriate technical measures, and certificate expiry without notice may breach that standard.

#8

DNS-01 through their API — which provider, RackNerd themselves?

#9

Three months clean? I had silent failures at month four.

conbini > datacenter snacks
#10

Acme.sh still king

not your keys, not your coins

Post a reply

You need an account to reply. Log in or register to join the conversation.

Post reply Preview Save draft