Skip to content

Enhance SSL at scale — Let's Encrypt automation, custom CA, expiry monitoring

Run SSL provisioning across thousands of Enhance websites — Let's Encrypt automation, custom CA option, monitoring for renewal failures before they hit production.

You run an Enhance cluster with 1,200 websites, SSL auto-provisioning enabled at the panel level, and one of those websites is showing a NET::ERR_CERT_DATE_INVALID in Chrome this morning because its certificate expired 18 hours ago and the renewal failed silently — a DNS misconfig on the customer’s side that Let’s Encrypt’s HTTP-01 challenge couldn’t satisfy. Enhance is happy to keep retrying once a day, but nothing escalated. SSL at scale is not “enable Let’s Encrypt and forget it” — it’s the renewal-monitoring half nobody implements until a customer files a panicked ticket.

What’s happening

Enhance SSL provisioning works in three modes:

  • Let’s Encrypt (default) — the panel runs an ACME client per website, satisfies HTTP-01 via the website’s own webroot, requests/renews certs through Let’s Encrypt’s production endpoint. Driven by the orchestrator on a per-website schedule, typically 30 days before expiry.
  • Custom CA / uploaded cert — for customers with wildcard certs from DigiCert/Sectigo/etc., the cert + chain + key are uploaded via UI or API. Renewal is the customer’s problem (or yours, if you’re managing it for them).
  • Self-signed — only for sites that don’t have public DNS yet (staging, internal). Useless from a browser’s perspective but maintains the TLS surface.

The failure modes that matter at scale:

  1. The customer points their DNS at a different IP (Cloudflare, dev environment, accidentally) and the HTTP-01 challenge can no longer reach the Enhance app server. Cert expires.
  2. The customer adds a subdomain to the website’s domain list but the renewal happens before the new subdomain has DNS — the ACME order fails because one name in the SAN list doesn’t validate.
  3. Let’s Encrypt rate-limits the cluster’s IP for some reason (usually too many failed orders) and a wave of legitimate renewals starts failing with tooManyRequests.
  4. The custom-CA renewals nobody is tracking — the manager who uploaded a 2-year cert 23 months ago has left the company.

Monitoring needs to catch all four. The right pattern is two separate watches: an active probe that connects to every customer hostname every few hours and reads the cert’s notAfter, plus a passive watch on the orchestrator’s ACME log for failed orders.

How to verify

List every certificate Enhance currently manages and its days-to-expiry:

TOKEN=$(vault kv get -field=value secret/enhance/admin/current)
ORCH="https://panel.example.com"

curl -sH "Authorization: Bearer $TOKEN" "$ORCH/api/certificates?limit=2000" | \
  jq -r '.certificates[] | "\(.id) \(.primary_domain) \(.expires_at) \(.issuer) \(.type)"' | \
  awk '{
    cmd = "date -d \""$3"\" +%s"; cmd | getline expires; close(cmd)
    days = int((expires - systime()) / 86400)
    printf "%-40s %s (in %d days) %s %s\n", $2, $3, days, $4, $5
  }' | sort -k4 -n | head -20

The output is sorted by remaining days; anything under 14 days is a problem to investigate now.

Look at the ACME log for recent failures:

journalctl -u enhance-orchestrator --since '24 hours ago' | \
  grep -iE '(acme|letsencrypt|cert).*?(fail|error|timeout|unauthorized)' | head -50

Active probe — actually open a TLS connection to a hostname and read the cert expiry:

DOMAIN="customer42.com"
echo | openssl s_client -servername "$DOMAIN" -connect "$DOMAIN:443" 2>/dev/null | \
  openssl x509 -noout -dates -subject -issuer

Cross-check against the panel — if Enhance says the cert is valid for 60 days but openssl s_client says it expires in 3 days, the customer’s DNS is pointing somewhere other than the Enhance app server, and the cert Enhance is renewing isn’t the one users are actually seeing:

ENHANCE_EXPIRY=$(curl -sH "Authorization: Bearer $TOKEN" \
  "$ORCH/api/websites/$SITE_ID" | jq -r '.ssl.expires_at')
LIVE_EXPIRY=$(echo | openssl s_client -servername "$DOMAIN" -connect "$DOMAIN:443" 2>/dev/null | \
  openssl x509 -noout -enddate | cut -d= -f2)

echo "Panel says: $ENHANCE_EXPIRY"
echo "Live cert:  $LIVE_EXPIRY"

These two should be the same date give or take an hour. If they differ by a week or more, DNS is pointing somewhere else.

The fix

A monitoring script that probes every domain in the panel inventory, compares the live cert with what the panel believes, and emits Prometheus textfile metrics. Save as /usr/local/bin/enhance-cert-probe:

#!/usr/bin/env bash
# /usr/local/bin/enhance-cert-probe
# Probe every website's domain, write Prom textfile metrics
set -euo pipefail

TOKEN=$(vault kv get -field=value secret/enhance/monitoring/current)
ORCH="${ORCH:-https://panel.example.com}"
METRICS_FILE="/var/lib/node_exporter/textfile/enhance_cert.prom"
TMP="${METRICS_FILE}.tmp"

mkdir -p "$(dirname "$METRICS_FILE")"
: > "$TMP"

cat >> "$TMP" <<'EOF'
# HELP enhance_cert_days_to_expiry Days until live cert expiry, probed via openssl s_client
# TYPE enhance_cert_days_to_expiry gauge
# HELP enhance_cert_mismatch 1 if panel-known expiry differs from live cert by more than 24h
# TYPE enhance_cert_mismatch gauge
# HELP enhance_cert_probe_failed 1 if the active probe could not establish TLS
# TYPE enhance_cert_probe_failed gauge
EOF

curl -sH "Authorization: Bearer $TOKEN" "$ORCH/api/websites?limit=2000" | \
  jq -r '.websites[] | "\(.id)\t\(.primary_domain)\t\(.ssl.expires_at // "none")"' | \
  while IFS=$'\t' read -r site_id domain panel_expiry; do
    [[ -z "$domain" || "$domain" == "null" ]] && continue

    # Active probe
    live_expiry_str=$(echo | timeout 10 openssl s_client -servername "$domain" \
      -connect "${domain}:443" 2>/dev/null | \
      openssl x509 -noout -enddate 2>/dev/null | cut -d= -f2 || true)

    if [[ -z "$live_expiry_str" ]]; then
      echo "enhance_cert_probe_failed{domain=\"$domain\",site=\"$site_id\"} 1" >> "$TMP"
      continue
    fi

    live_expiry_epoch=$(date -d "$live_expiry_str" +%s 2>/dev/null || echo 0)
    now=$(date +%s)
    days_left=$(( (live_expiry_epoch - now) / 86400 ))

    echo "enhance_cert_days_to_expiry{domain=\"$domain\",site=\"$site_id\"} $days_left" >> "$TMP"
    echo "enhance_cert_probe_failed{domain=\"$domain\",site=\"$site_id\"} 0" >> "$TMP"

    # Mismatch check
    if [[ "$panel_expiry" != "none" ]]; then
      panel_expiry_epoch=$(date -d "$panel_expiry" +%s 2>/dev/null || echo 0)
      diff=$(( panel_expiry_epoch - live_expiry_epoch ))
      diff=${diff#-}
      if (( diff > 86400 )); then
        echo "enhance_cert_mismatch{domain=\"$domain\",site=\"$site_id\"} 1" >> "$TMP"
      else
        echo "enhance_cert_mismatch{domain=\"$domain\",site=\"$site_id\"} 0" >> "$TMP"
      fi
    fi
  done

mv "$TMP" "$METRICS_FILE"

Cron it every 30 minutes:

echo "*/30 * * * * nobody /usr/local/bin/enhance-cert-probe >/dev/null 2>&1" \
  > /etc/cron.d/enhance-cert-probe

Prometheus alerting rules:

# /etc/prometheus/rules/enhance-ssl.yml
groups:
  - name: enhance-ssl
    rules:
      - alert: EnhanceCertExpiringSoon
        expr: enhance_cert_days_to_expiry < 14
        for: 30m
        labels:
          severity: warning
        annotations:
          summary: "{{ $labels.domain }} cert expires in {{ $value }} days"

      - alert: EnhanceCertExpiringCritical
        expr: enhance_cert_days_to_expiry < 5
        for: 30m
        labels:
          severity: critical
        annotations:
          summary: "{{ $labels.domain }} cert expires in {{ $value }} days — renewal blocked"

      - alert: EnhanceCertProbeFailed
        expr: enhance_cert_probe_failed == 1
        for: 1h
        labels:
          severity: warning
        annotations:
          summary: "Cannot probe TLS for {{ $labels.domain }} — DNS or routing issue"

      - alert: EnhanceCertMismatch
        expr: enhance_cert_mismatch == 1
        for: 2h
        labels:
          severity: warning
        annotations:
          summary: "Panel-known cert differs from live cert for {{ $labels.domain }} (likely external DNS)"

For domains where the customer wants a custom CA (DigiCert/Sectigo wildcard, etc.) — upload via API:

curl -sH "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -X POST "$ORCH/api/websites/$SITE_ID/ssl/upload" \
  -d "{
    \"certificate\": \"$(cat /tmp/customer.crt | sed ':a;N;$!ba;s/\n/\\n/g')\",
    \"chain\": \"$(cat /tmp/intermediate.crt | sed ':a;N;$!ba;s/\n/\\n/g')\",
    \"private_key\": \"$(cat /tmp/customer.key | sed ':a;N;$!ba;s/\n/\\n/g')\",
    \"auto_renew\": false
  }"

The above must run with auto_renew: false for a custom CA — the panel’s ACME client cannot renew a DigiCert cert and will silently keep trying to issue a Let’s Encrypt overlay if you forget. The renewal calendar for custom CAs is yours to track. A separate spreadsheet (or, better, a YAML file in the same ops repo as the rest of your config) listing each custom cert + its expiry + its renewal owner is the minimum:

# ops-repo/enhance/custom-certs.yml
- domain: bigcustomer.com
  site_id: site-9f3c
  issuer: DigiCert
  serial: 0E45...
  expires: 2027-01-14
  owner: alice@msp.com
  renewal_workflow: bigcustomer-it-ticket-#34521

- domain: enterprise-app.example.com
  site_id: site-2a1f
  issuer: Sectigo
  serial: 7B22...
  expires: 2026-08-30
  owner: ops@msp.com
  renewal_workflow: internal-vault-secret/enterprise-cert/2026-08

A pre-renewal report — runs monthly, emails the custom-CA owners 90 days before expiry:

#!/usr/bin/env bash
# /usr/local/bin/enhance-custom-cert-reminder
set -euo pipefail

YAML=/etc/enhance-ops/custom-certs.yml
THRESHOLD_DAYS=90
NOW=$(date +%s)

yq -o=json e '.[]' "$YAML" | jq -c '.' | while read -r row; do
  domain=$(echo "$row" | jq -r '.domain')
  expires=$(echo "$row" | jq -r '.expires')
  owner=$(echo "$row" | jq -r '.owner')

  exp_epoch=$(date -d "$expires" +%s)
  days=$(( (exp_epoch - NOW) / 86400 ))

  if (( days < THRESHOLD_DAYS )); then
    mail -s "Cert renewal due: $domain in $days days" "$owner" <<EOF
The custom certificate for $domain expires in $days days ($expires).
Renewal workflow: $(echo "$row" | jq -r '.renewal_workflow')

This is an automated reminder from the Enhance ops runbook.
EOF
  fi
done

Two rules worth keeping: the active probe should run from a host that is not one of your Enhance app servers — a probe that succeeds because it’s on the same host as the cert it’s checking tells you nothing about external reachability. And the alert for “cert expires in 5 days” should page, not just notify — at 5 days you don’t have time for a Monday-morning standup discussion.

Enhance SSL operations at scale — with active probing, ACME log monitoring, and a custom-CA renewal calendar — are part of how we run hosting infrastructure under Managed Cloud Ops with full monitoring including cert health. Open a TLS audit if you’re not sure how many of your sites would survive a renewal failure unnoticed.