Repository navigation
fix(agent-bridge): make the regenerate-cert endpoint actually mint a new cert (#10467) - #10715
Merged
diegosouzapw merged 1 commit intoAug 20, 2026
Conversation
…new cert (diegosouzapw#10467) POST /api/tools/agent-bridge/cert/regenerate called generateCert() with no arguments. generateCert() returns the existing paths untouched whenever server.key and server.crt are both on disk, so on any machine that had already started the bridge the endpoint was a no-op: the button reported success, the download route kept serving the old file with the same md5, and a cert predating diegosouzapw#6494 could never be replaced from the UI. Give generateCert an opt-in { force } and have the regenerate route pass it. Every other caller — the MITM settings route, the bridge server route and the manager — only needs a cert to exist, so they keep the existing short-circuit and are unchanged. Fixes diegosouzapw#10467
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…new cert (diegosouzapw#10467) (diegosouzapw#10715) Merged via merge-train (release/v3.8.50, batch1 2026-08-20) — static gates (typecheck/file-size/complexity/cognitive/changelog) green on the combined tree; test:unit reds observed in the boarded run were verified pre-existing on the pure release tip (unrelated flake), not caused by this PR. Thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #10467 — "Regenerate Cert does not regenerate the cert".
POST /api/tools/agent-bridge/cert/regeneratecalledgenerateCert()with no arguments, andgenerateCert()short-circuits whenever both files already exist:So on any machine that had already started the bridge the endpoint was a no-op. It still answered
{ ok: true }with the two paths, which is why the UI reported success while/cert/downloadkept serving the identical file — matching the reporter's observation that the md5 never changed and the SANs added in #6494 never appeared.The route's own comment documented this as intentional ("the function is idempotent … If a caller needs a fresh cert they must delete the old one manually"), but that leaves the regenerate button with nothing to do, and there is no other UI path to delete the cert.
Change
generateCerttakes an opt-in{ force }, and the regenerate route is the one caller that passes it.The other three callers only need a certificate to exist —
src/app/api/settings/mitm/route.ts,src/app/api/tools/agent-bridge/server/route.tsandsrc/mitm/manager.ts— so they keep the existing short-circuit and are untouched. Nothing regenerates a cert that used to be reused.Tests
New file
tests/unit/agent-bridge-cert-regenerate-force-10467.test.ts, 4 cases,node:testto match the siblingagent-bridge-cert-*tests. Each case runs against its own tempDATA_DIR, so no test touches the real cert store.generateCert()with a cert on diskgenerateCert({ force: true })with a cert on diskX509Certificateand carries a SAN for everyANTIGRAVITY_TARGET.hostsentry, so a forced cert can't silently regress #6494generateCert({ force: true })with nothing on diskThe suite pins the bug rather than describing the fix — against the unpatched
generate.ts, exactly the one case that targets it fails:With the patch:
pass 4, fail 0.Commands run
The 10 pre-existing failures in that set are environment-bound, not related to this change — they assert POSIX behaviour (
chmod 0644aftercp,umask 0077,/etc/hostswrites,sudofallback) plus two Windows cert-store lookups. The set is identical before and after; only the 4 new tests moved the counts.I could not run
npm run test:coverageend to end on this machine — the full runner needs far more than a Windows dev box will finish in reasonable time. The changed production lines are covered by the new tests: theforcebranch and the preserved reuse branch are each asserted directly, and the route's single changed line is the call site.Changed files
src/mitm/cert/generate.ts—{ force }optionsrc/app/api/tools/agent-bridge/cert/regenerate/route.ts— pass{ force: true }tests/unit/agent-bridge-cert-regenerate-force-10467.test.ts— new