# Certificates

Source: https://openpanel.sh/docs/domains/certificates

How HTTPS works for opnl.app addresses, and for your own domains with a certificate you upload or behind Cloudflare.

Every domain OpenPanel serves is HTTPS. You never request, upload or renew a certificate for an opnl.app address; for your own domain you choose where its certificate comes from.

## opnl.app addresses [#opnlapp-addresses]

HTTPS is on for every opnl.app address from the moment it exists:

- **Visitors connect over HTTPS** to Cloudflare, which stands in front of opnl.app.
- **Cloudflare connects to OpenPanel's edge over TLS too**, so the request is encrypted all the way to the edge.
- **From the edge to your service**, the request travels inside the [agent](/docs/servers/agent)'s own TLS connection to your server, and reaches the container as plain HTTP. Your service listens on plain HTTP on its port; it needs no certificate of its own.
- **Plain HTTP** requests are sent on to the same address with `https://`.

## Your own domains [#your-own-domains]

A domain is served only once OpenPanel has verified that it is yours ([check its records](/docs/domains/own-domain#check-the-records)), and only on an OpenPanel that serves own domains. Its HTTPS then comes one of two ways:

| Way | The CNAME to `edge.openpanel.sh` | What visitors see |
|---|---|---|
| **Behind Cloudflare** | Proxied (orange cloud), with the zone's SSL/TLS mode **Full** | Cloudflare's certificate. Behind it, Cloudflare reaches the edge, which answers with its own. See [Domains on Cloudflare](/docs/domains/cloudflare). |
| **A certificate you upload** | DNS only, at any DNS host | Your certificate, served by the edge for that domain. |

With Cloudflare's **Full (strict)** mode, upload a certificate Cloudflare trusts for the domain, such as a free Cloudflare Origin CA certificate: Cloudflare's certificate faces visitors, yours sits behind it.

Certificates from Let's Encrypt, made by the edge by itself at a domain's first visit, are built but not switched on.

## Upload a certificate [#upload-a-certificate]

Any certificate for the domain works, from any certificate authority: one you bought, one from your company's own authority, or a Cloudflare Origin CA certificate. The domain must be verified first.

<Tabs items={["Console","CLI","API"]}>
<Tab value="Console">
On the **Domains** page, open the domain's menu and choose **Upload certificate**. Paste the chain and the key, or choose their files.
</Tab>

<Tab value="CLI">
```sh
openpanel domains certificate app.example.com --project shop --chain fullchain.pem --key privkey.pem
```

```text
app.example.com now serves the certificate for app.example.com, valid until 2027-03-01 23:59 UTC.
```

`openpanel domains certificate app.example.com` shows the names, issuer and dates of the one it has.
</Tab>

<Tab value="API">
```sh
curl -X PUT https://openpanel.sh/api/v1/domains/$DOMAIN_ID/certificate \
  -H "Authorization: Bearer $OPENPANEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --rawfile chain fullchain.pem --rawfile key privkey.pem '{chain: $chain, key: $key}')"
```

The answer is the domain with `certificateSource: "uploaded"`, `certificateExpiresAt`, and a `certificate` with its `names`, `issuer`, `notBefore`, `notAfter` and SHA-256 `fingerprint`. `GET` on the same path reads it again; the key is never returned. From an AI agent, the MCP tool is `domains_certificate_upload`.
</Tab>
</Tabs>

What OpenPanel checks before it keeps anything:

- **The chain** is PEM certificates with yours first, each signed by the one after it. Include the intermediates; the root may be left out.
- **Your certificate covers the domain**, by name or by a wildcard such as `*.example.com`, and is valid now, for at least another day.
- **The key** is the certificate's own, RSA of 2048 bits or more, ECDSA or Ed25519, and has no passphrase (remove one with `openssl pkey -in key.pem -out plain.pem`).

The key is sealed twice: once for OpenPanel's own records and once for the edge, the only place it is opened. The edge serves the certificate for that domain within a few seconds, and nothing else changes for the domain's other settings.

### Renew and remove [#renew-and-remove]

- **Expiry.** The domain's row shows when the certificate expires, and turns amber 21 days before. An expired certificate is not served: the edge falls back to its own, which only Cloudflare's proxy accepts.
- **Renew** by uploading the new certificate the same way; it replaces the old one at once.
- **Remove** it with **Remove certificate** in the domain's menu, `openpanel domains certificate app.example.com --remove`, or `DELETE /api/v1/domains/{domainId}/certificate`.

Uploading and removing need deploy access to the project, the same as adding the domain.

## What can go wrong [#what-can-go-wrong]

| Message | What it means |
|---|---|
| "This certificate does not cover app.example.com: it is for …" | The certificate is for other names. |
| "This private key does not belong to the certificate." | The key was made with another certificate. |
| "Certificate 2 in the chain did not sign certificate 1." | The chain is out of order, or holds a certificate that does not belong. |
| "The first certificate is a certificate authority's." | Put your domain's certificate first. |
| "This certificate expired on …" or "is valid only from …" | Upload one that is valid now. |
| "Verify app.example.com first." | The domain's TXT record has not been checked yet. |
| "Own domains are not served on this OpenPanel yet …" | Uploading opens once own domains are switched on. |

<Cards>
<Card href="/docs/domains/own-domain" title="Your own domain" description="Adding a domain, its records and the check." />

<Card href="/docs/domains/cloudflare" title="Domains on Cloudflare" description="Records written by OpenPanel, behind Cloudflare's certificate." />

<Card href="/docs/security" title="Security model" description="What OpenPanel stores and how it protects it." />
</Cards>