setup-origin: ask the registry to sign, serve the chain, renew on a timer - #25
Merged
Merged
Conversation
…imer The registry now runs a certificate authority for the names it holds (moshcoder/moshcode#519). With MOSHPIT_API_KEY set, setup-origin.sh sends a CSR for the name to POST /api/moshpit/tlds/:tld/certs and writes the chain it returns (leaf, issuer, root) over the certificate nginx serves, so any client that trusts the pit's root, TronBrowser or a box that ran moshcode dns enable, accepts the name with no pin lookup and no per-name import. Same key, so the published pin does not move and pin-checking clients keep working. The self-signed certificate stays as the fallback: no key, --self-signed, a registry without a CA, or a refusal all leave it in place and say so. With a signed chain the box trusts the pit's root instead of the leaf, under the same file moshcode uses. The 30-day leaf is renewed by scripts/moshpit-renew.sh, run daily by moshpit-renew.timer, which the script installs the first time it gets a signed certificate; the API key it needs is kept root-only at /etc/moshpit/renew.env. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
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.
What
setup-origin.shasks the registry to sign the name's certificate and serves the chain, so a client that trusts the pit's root (TronBrowser, a box that ranmoshcode dns enable) accepts the name over https with no pin lookup and no per-name import. Renewal is a daily timer the script installs itself.Registry side: moshcoder/moshcode#519. Client side: moshcoder/moshcode#520 (v0.102.0) and profullstack/tronbrowser.dev#109.
How
MOSHPIT_API_KEYset and not--self-signed: checkGET /api/moshpit/cais enabled, make a CSR from the same key (openssl req -new),POST /api/moshpit/tlds/<tld>/certs { label, csr }, and write the returned chain (leaf, issuer, root) over$CERTDIR/<name>.crt, which is what the nginx block already serves. Same key, so the published pin does not move and pin clients keep working. The registry's root is kept at$CERTDIR/moshpit-root-ca.crt.--self-signed, a registry with no CA (enabled: falseor 503), a refusal (the body is shown), a chain that does not parse or does not name the host.moshpit-root-ca.crt, the same filemoshcode dns enableuses, instead of the leaf.scripts/moshpit-renew.sh: for each registry-signed certificate under$CERTDIR(issuer is not the name itself) within 10 days of expiry, re-runsetup-origin.sh <name> --no-trust. Self-signed names are never touched. Reads the API key from/etc/moshpit/renew.env, which the script writes root-only (umask 077) on the first signed issuance.systemd/moshpit-renew.{service,timer}: daily, randomised by an hour, persistent. Installed and enabled bysetup-origin.shon the first signed certificate whensystemctlexists, from/opt/moshpit/systemd, so there is no step to remember.--self-signedflag andMOSHPIT_SELF_SIGNED,MOSHPIT_RENEW_ENVenvironment; help updated.Verified
tests/setup-origin-registry.test.ts(5): a dry run with a key says it would ask the registry and names the exact endpoint;--self-signedand no-key runs never mention the registry;moshpit-renew.shexits 0 with a message on a box that was never signed, and with a fakesetup-origin.shrenews only the signed certificate within the window while leaving the self-signed one and the still-valid signed one alone.tests/setup-origin.test.tsunchanged and green; full suite 92/92.sh -non both scripts.MOSHPIT_API_KEYset, andopenssl s_client -connect <name>:443 -servername <name>should then show a chain issued byCN=Moshpit Issuing CA.🤖 Generated with Claude Code