---
title: "Managing SSL and TLS Certificates"
description: "Monitor automated TLS certificate provisioning, CAA validation requirements, and renewal for custom domains."
---

> Documentation Index
> Fetch the complete documentation index at: https://shaf.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing SSL and TLS Certificates

# Managing SSL and TLS Certificates

Custom short domains require valid TLS encryption to prevent browser security warnings and enable secure Anycast routing. This guide walks through Shaf's automated certificate provisioning lifecycle, certificate status monitoring, and resolution of DNS authorization challenges.

---

## Prerequisites

- Workspace permissions: `Owner` or `Admin` role in your Shaf organization.
- A custom domain registered in Shaf with a CNAME record pointing to `cname.shaf.app`.
- DNS control to add Certification Authority Authorization (CAA) records if your domain restricts certificate authorities.

---

## Implementation Recipe

1. **Inspect Certificate Status**

   Check the current TLS validation state in the dashboard under **Settings → Domains** or query the SSL endpoint:

   ```bash
   curl -X GET "https://shaf.app/api/v1/domains/dom_01j8k3m4n5p6q7r8s9t0/ssl" \
     -H "Authorization: Bearer $SHAF_API_TOKEN"
   ```

   **Expected response (`200 OK`):**

   ```json
   {
     "hostname": "go.acme.com",
     "ssl": {
       "status": "active",
       "method": "cname",
       "type": "universal",
       "issuer": "Let's Encrypt Authority",
       "expiresAt": "2027-02-15T00:00:00Z",
       "autoRenew": true
     }
   }
   ```
2. **Understand Certificate Lifecycle States**

   Cloudflare for SaaS provisions certificates automatically through Let's Encrypt or Google Trust Services:

   | State | Description | Duration |
   | :- | :- | :- |
   | `pending_validation` | Hostname submitted; CA validating CNAME or TXT challenge. | 1–5 minutes |
   | `initializing` | Certificate issued; distributing private key securely to 300+ edge colos. | 1–2 minutes |
   | `active` | TLS termination active worldwide over HTTP/2 and HTTP/3. | Active (auto-renews) |
   | `validation_timed_out` | DNS challenge could not be resolved within timeout period. | Requires manual re-check |
3. **Configure CAA Records (If Restricting CAs)**

   If your domain's DNS publishes CAA (Certification Authority Authorization) records, you must explicitly permit the certificate authorities utilized by Cloudflare for SaaS:

   | Type | Host | Value | Flags / Tag |
   | :- | :- | :- | :- |
   | `CAA` | `@` (apex) | `letsencrypt.org` | `0 issue` |
   | `CAA` | `@` (apex) | `pki.goog` | `0 issue` |
   | `CAA` | `@` (apex) | `digicert.com` | `0 issue` |
4. **Trigger Certificate Re-Check**

   If DNS propagation was delayed during initial domain setup, trigger an immediate validation re-check:

   ```bash
   curl -X POST "https://shaf.app/api/v1/domains/dom_01j8k3m4n5p6q7r8s9t0/ssl/recheck" \
     -H "Authorization: Bearer $SHAF_API_TOKEN"
   ```

---

## Verification

Verify certificate issuance and inspect the cryptographic chain from your terminal:

1. Test the TLS connection with OpenSSL:
   ```bash
   openssl s_client -connect go.acme.com:443 -servername go.acme.com -brief
   ```
   **Expected output:**
   ```text
   CONNECTION ESTABLISHED
   Protocol : TLSv1.3
   Cipher   : TLS_AES_128_GCM_SHA256
   Verify return code: 0 (ok)
   ```

2. Probe using `curl` with verbose SSL handshaking:
   ```bash
   curl -IvI "https://go.acme.com" 2>&1 | grep -E "SSL certificate|server certificate"
   ```
   **Expected output:**
   ```text
   *  SSL certificate verify ok.
   * Server certificate:
   *  subject: CN=go.acme.com
   ```

---

## Common Gotchas

| Issue / Error | Root Cause | Solution |
| :--- | :--- | :--- |
| `CAA Record Restriction (Error 526)` | Domain CAA records forbid Let's Encrypt or Google Trust Services. | Add `0 issue "letsencrypt.org"` and `0 issue "pki.goog"` to your DNS zone. |
| Status stuck at `pending_validation` | CNAME record does not resolve to `cname.shaf.app` or registrar TTL is high. | Verify CNAME using `dig +short CNAME go.acme.com`, then click **Re-check Status**. |
| `Cloudflare 525 Handshake Failed` | Request arrived at an edge colo before certificate deployment finished. | Allow 1–2 minutes after `active` status before directing production traffic. |
| Automatic renewal failure | CNAME record was removed or altered after initial setup. | Keep the CNAME record permanently pointed to `cname.shaf.app` to ensure automated 30-day renewals. |

Source: https://shaf.app/docs/how-to/domains-and-branding/ssl-and-certificates/index.mdx
