> ## Documentation Index
> Fetch the complete documentation index at: https://sariva.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up certificates

> Run the certificate flow after the wizard emits the scaffold — the self-signed chain, fresh bring-your-own-CA, and migrating a running cluster to your CA, with exact commands.

> [!NOTE]
>
> Kubernetes/EKS only. On a VM, skip this page.

This page executes the certificate-source decision you made in [mTLS certificate options](https://sariva.mintlify.site/prerequisites/cfk/mtls.md). Every `<scaffold>/...` path below refers to your gitops repo working tree — the wizard's output directory, committed and since grown by Sariva's pull requests. The `clusters/<cluster>/manifests/` directories referenced below exist once the cluster's [DM-deploy](https://sariva.mintlify.site/operate/deploy-cluster-cfk.md) PR has merged — the wizard itself emits only the `cfk-operator/` bootstrap.

## Option 2 — self-signed CA (emitted end-to-end)

The scaffold emits the whole chain; you apply it in the wave order from the scaffold's `cfk-operator/README.md`:

**1. Install cert-manager (wave 1):**

```bash theme={null}
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm upgrade --install cert-manager jetstack/cert-manager \
  --namespace cert-manager --create-namespace --set crds.enabled=true
```

**2. Apply the emitted chain (wave 2):**

```bash theme={null}
kubectl apply -k <scaffold>/<stage>/<eks>/cfk-operator/
```

This creates, in order:

| Resource | Name | Namespace | Purpose |
| - | - | - | - |
| ClusterIssuer (selfSigned) | `confluent-selfsigning-issuer` | cluster-scoped | Bootstraps the CA |
| Certificate (the CA) | `confluent-ca` | `cert-manager` | Mints the CA keypair into Secret `confluent-ca` |
| ClusterIssuer (CA) | `confluent-ca-issuer` | cluster-scoped | Signs every component certificate |

**3. Component certificates** are part of the cluster manifests (wave 3 — emitted with the cluster's [DM-deploy](https://sariva.mintlify.site/operate/deploy-cluster-cfk.md) PR, not by the wizard): one `Certificate` per component (`kafka-tls`, `kraftcontroller-tls`, `schemaregistry-tls`), producing Secrets `tls-kafka`, `tls-kraftcontroller`, `tls-schemaregistry`. Each is emitted with:

```yaml theme={null}
privateKey:
  encoding: PKCS8          # Kafka's PEM readers reject PKCS#1 keys
  rotationPolicy: Always   # a re-issue actually rotates the private key
```

No further action — cert-manager renews on its own cadence (90-day certificates, renewed with margin).

## Bring your own CA — fresh setup

Starting a new cluster on your own CA from day one: run wave 1 as normal, then **skip the emitted self-signed pieces** — seed the CA Secret yourself and create only the CA issuer.

**1. Install cert-manager and the CFK operator (wave 1)** — unchanged from the self-signed flow.

**2. Create the namespace, then seed the CA Secret from your CA** (Sariva never sees or holds the key):

```bash theme={null}
kubectl apply -f <scaffold>/<stage>/<eks>/cfk-operator/namespace.yaml
kubectl create secret tls confluent-ca \
  --namespace cert-manager \
  --cert=/path/to/your-ca.crt \
  --key=/path/to/your-ca.key
```

**3. Create only the CA issuer** — do **not** apply the emitted `certmanager-bootstrap.yaml` (its self-signed CA `Certificate` would overwrite your seeded Secret with a generated CA). Apply just this:

```yaml theme={null}
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: confluent-ca-issuer
spec:
  ca:
    secretName: confluent-ca
```

**4. Apply the cluster manifests (wave 3) as normal** — every component certificate (and Sariva's client certificate) is issued from your CA from the start; nothing to rotate later.

**5. Verify** — same check as the migration flow below (`tls-kafka`'s issuer must be your CA).

## Bring your own CA — migrating an existing cluster

Switching a running cluster to a **customer-owned CA** is a CA-Secret swap: cert-manager re-issues every component certificate (and Sariva's client certificate) from the new CA. It must be a **full chain swap** — a partial swap fails silently, because (a) the self-signed CA `Certificate`, if left in place, regenerates the old CA back into the Secret, and (b) cert-manager reuses existing component Secrets rather than re-minting them.

The validated recipe, in order:

**1. Tear down the cluster (certificates are cluster-lifecycle here):**

```bash theme={null}
kubectl delete -k <scaffold>/<stage>/<eks>/clusters/<cluster>/manifests/
kubectl delete pvc --all -n confluent
```

**2. Delete the whole old CA chain — all four pieces:**

```bash theme={null}
kubectl delete clusterissuer confluent-selfsigning-issuer
kubectl delete certificate confluent-ca -n cert-manager
kubectl delete secret confluent-ca -n cert-manager
kubectl delete clusterissuer confluent-ca-issuer
```

**3. Seed the CA Secret from your CA** (the CA certificate and key you own — Sariva never sees or holds the key):

```bash theme={null}
kubectl create secret tls confluent-ca \
  --namespace cert-manager \
  --cert=/path/to/your-ca.crt \
  --key=/path/to/your-ca.key
```

**4. Recreate only the CA issuer** — not the self-signing issuer and not the CA `Certificate` (either would regenerate a new CA over your seeded Secret). Apply just this:

```yaml theme={null}
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: confluent-ca-issuer
spec:
  ca:
    secretName: confluent-ca
```

**5. Re-apply the cluster manifests** — components come up with certificates signed by your CA:

```bash theme={null}
kubectl apply -k <scaffold>/<stage>/<eks>/clusters/<cluster>/manifests/
```

**6. Verify before trusting anything** — the broker certificate's issuer must be your CA:

```bash theme={null}
kubectl get secret tls-kafka -n confluent -o jsonpath='{.data.tls\.crt}' \
  | base64 -d | openssl x509 -noout -issuer
```

**7. Rotate Sariva's client certificate too** — it must be signed by the same CA the brokers now trust. Delete Sariva's client-cert Secret (in Sariva's namespace) so cert-manager re-issues it from the new CA, then restart the Sariva pod so its Kafka client picks up the new identity:

```bash theme={null}
kubectl delete secret tls-sariva-client -n sariva-platform
kubectl rollout restart deploy/sariva-platform -n sariva-platform
```

## Sariva's own client certificate

Sariva talks to the brokers as an mTLS client, and its identity comes from a small cert-manager `Certificate` **in Sariva's namespace** — signed by the same CA issuer as the components, so the brokers trust it. Apply it once (any cert source that ends in a `confluent-ca-issuer` works the same way):

```yaml theme={null}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: sariva-client-tls
  namespace: sariva-platform
spec:
  secretName: tls-sariva-client
  commonName: sariva-platform
  issuerRef:
    name: confluent-ca-issuer
    kind: ClusterIssuer
```

Three things about it matter:

* **The Secret name is a convention.** The cluster registration references it as `k8s://sariva-platform/tls-sariva-client`, and the Helm chart's `kafkaClientCerts` block wires the read permission for it — keep the name unless you change both.
* **The `commonName` is Sariva's Kafka identity.** With authorization enabled, the principal is derived from the CN's first label — `CN=sariva-platform` → `User:sariva-platform` — and the emitted bootstrap ACL Job grants the describe-only permissions to exactly that principal. If you mint this certificate with a different CN, set the matching principal at wizard/emit time or Sariva is denied everything.
* **It rotates with the CA.** If you later swap to your own CA (the migration flow above), delete this Secret and restart the Sariva pod — step 7 of that flow.

## Operational rules (learned the hard way)

⚠WARNING

**Never bare-delete a component TLS Secret** (`tls-kafka` etc.) to force a re-issue: CFK holds a finalizer on component Secrets, so the delete wedges in Terminating and cert-manager cannot re-issue. Rotate through cert-manager instead — the Certificates carry `rotationPolicy: Always`, so re-issuing the *Certificate* rotates the key properly, and CFK rolls the brokers one at a time to pick it up.

* **PKCS#8 is required.** Kafka's PEM readers reject PKCS#1 private keys; every emitted Certificate pins `privateKey.encoding: PKCS8`. If you hand-author Certificates (options 3/4), set it too.
* **Certificate rotation rolls brokers.** When a component certificate changes, CFK restarts that component's pods one at a time — expect a rolling restart, not downtime.
* **The CA `Certificate` is deliberately not rotation-pinned** — rotating a CA key on renewal would break trust in every leaf certificate at once.

## Continue the deployment path

> [card] [Next: create the runtime Secret](https://sariva.mintlify.site/install-setup/runtime-secret.md)
>
> Continue the install — fill setup-secret.sh before deploying Sariva with Helm.

> [card] [Back: AWS EKS + Confluent Platform (CFK)](https://sariva.mintlify.site/deploy/aws-eks-cfk.md)
>
> Return to the CFK path map.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.