Skip to content

fix(certs): replace the CA when the TLD changes - #182

Open
hanming5 wants to merge 1 commit into
flock-php:mainfrom
hanming5:fix/renew-ca-on-tld-change
Open

hanming5 wants to merge 1 commit into
flock-php:mainfrom
hanming5:fix/renew-ca-on-tld-change

Conversation

@hanming5

Copy link
Copy Markdown

Fixes #180

What and why

The local CA is name-constrained to the TLD it was created for, but certs.Ensure kept loading the existing CA after the TLD changed, so every certificate for the new TLD was rejected even with the CA trusted.

Ensure now creates a new CA when the existing one's name constraints don't permit the configured TLD (a CA without constraints is kept). The rest follows from existing behavior:

  • site certificates are reissued because SiteCert checks the signing CA, and in-memory leaves are keyed by CA fingerprint;
  • flock install trusts the new root, since the trust checks on macOS (verify-cert), Windows (certutil -store Root <fingerprint>) and Linux (anchor file comparison) all fail for it.

The old root stays in the trust stores. It only covers the old TLD; removing it could be a follow-up if you want that.

How I tested it

  • New test TestReplacesCAWhenTheTLDChanges fails on main ("CA for .wsl was kept for .test") and passes with the change; plus TestKeepsCAWithoutNameConstraints.
  • go test for internal/certs, internal/web, internal/cli, internal/daemon on Windows; go vet, gofmt. I couldn't run -race locally.
  • Not tested end to end with a real TLD change.

Checklist

  • I tested this change
  • I updated the docs in docs/, or no docs change is needed
  • This changes only the daemon or CLI, not the apps
  • This changes the apps, and I made and tested the change on every platform:
    • macOS
    • Windows
    • Linux

The root is name-constrained to the TLD it was made for, and Ensure kept
loading it after the TLD changed, so browsers rejected every certificate
for the new TLD even with the CA trusted. Ensure now makes a new CA when
the existing one doesn't permit the TLD. Site certificates follow, since
they are reissued when signed by another CA, and `flock install` trusts
the new root because its trust checks go by fingerprint.

Fixes flock-php#180

This branch has not been deployed

No deployments
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.

CA is kept when the TLD changes, HTTPS breaks for the new TLD

1 participant