Skip to content

refactor(gateway)!: replace the file-configured proxy certificate with Admin.ImportCert - #1239

Merged
kvinwang merged 2 commits into
nextfrom
fix/gateway-cert-store-reload
Sep 24, 2026
Merged

kvinwang merged 2 commits into
nextfrom
fix/gateway-cert-store-reload

Conversation

@kvinwang

@kvinwang kvinwang commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Two changes to the gateway certificate store.

  1. Remove [core.proxy] cert_chain/cert_key (and base_domain). The configured certificate lived in no KV key, so every cert store reload built from KV dropped it and <id>.<base_domain> routing stopped for the whole base domain. Production deployments do not set it; certificates are issued by the distributed certbot and kept in KV. base_domain only named the domain for that certificate and is otherwise unread.
    A certificate issued elsewhere is now installed with the new Admin.ImportCert(domain, cert_pem, key_pem), which stores it in KV like an issued one, so it replicates and survives reloads. The gateway does not renew it.
    Breaking: these keys are now ignored. Deployments that set them must import the certificate through the admin API instead.
  2. add_cert only checked the replicated CertData.not_after, not the X.509 notAfter of the chain it serves, so a record with not_after = u64::MAX installed an expired chain. It now requires both.

Test harnesses: the proxy data-path suite imports its certificate through ImportCert; the cluster suite and tools/dev-stack.sh no longer configure one.

Verification: cargo test -p dstack-gateway 320 passed; clippy and fmt clean. test-run/proxy-e2e/run-proxy-tests.sh: 69 passed / 1 skipped (main), 67 passed / 1 skipped (no-TLS-ULP container); every arm reaches readiness only after ImportCert succeeds.

`CertStoreBuilder::add_cert` decided whether a certificate was still valid
from `CertData.not_after` alone, a replicated field, and never looked at the
`notAfter` of the chain it was about to serve. A record claiming `u64::MAX`
over an expired chain installed on every node that replicated it.

Both now have to be in the future. A record that outlives its chain delays
renewal, so it is logged. `get_cert_expiry` moves to `cert_store` so there
is one copy.
…h Admin.ImportCert

`[core.proxy] cert_chain`/`cert_key` installed a certificate that lived in
no KV key, so any cert store reload built from KV dropped it, taking
`<id>.<base_domain>` routing down with it. Production deployments do not set
it: certificates are issued by the distributed certbot and kept in KV.

Remove it, and `base_domain`, which only named the domain for it. A
certificate issued elsewhere is now installed with `Admin.ImportCert`, which
stores it in KV like an issued one, so it replicates and survives reloads.
The gateway does not renew it.

The proxy data-path suite imports its test certificate through the RPC; the
cluster suite and dev-stack.sh no longer configure one.
@kvinwang kvinwang changed the title fix(gateway): a certificate reload wiped the configured proxy certificate refactor(gateway)!: replace the file-configured proxy certificate with Admin.ImportCert Sep 24, 2026
@kvinwang
kvinwang force-pushed the fix/gateway-cert-store-reload branch from d4ae044 to cf0f3d0 Compare September 24, 2026 12:58
@kvinwang
kvinwang merged commit 3ae33ab into next Sep 24, 2026
15 checks passed
@kvinwang
kvinwang deleted the fix/gateway-cert-store-reload branch September 24, 2026 14:23
kvinwang added a commit that referenced this pull request Sep 25, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 8, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 10, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 11, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang added a commit that referenced this pull request Nov 16, 2026
PR #1239 removed the file-configured proxy certificate. The isolated
gateway fixture and tc-gos-setup-009 now import their *.localhost
certificate through the admin API, tc-gw-internal-001 asserts the removed
keys stay absent and the imported certificate survives a restart, and
tc-gw-certificat-006 counts the new expired-chain test. The new
tc-gw-admin-037 covers the ImportCert contract on a three-node cluster.

Signed-off-by: Kevin Wang <wy721@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant