Repository navigation
Reload certificate and key from disk on each step ca renew --daemon cycle - #1746
Open
Jimmyman1465 wants to merge 1 commit into
Open
Jimmyman1465 wants to merge 1 commit into
Jimmyman1465 wants to merge 1 commit into
Conversation
… cycle When `step ca renew --daemon` is initialized with file-based credentials, it previously cached `cert`, `key`, and `transport.TLSClientConfig.Certificates` at startup. If the certificate and private key on disk were rotated externally, subsequent daemon cycles kept renewing with the startup keypair (and idle mTLS connections) and wrote certificates bound to the stale public key over disk. Reload the on-disk keypair before each `RenewAndPrepareNext` cycle for file-backed daemons, validate that the private key matches the certificate's public key (skipping the cycle cleanly if mismatched), update the client transport certificate, and close idle keep-alive connections when the certificate bytes change. Fixes smallstep#1632
|
|
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.
Name of feature:
Reload certificate and private key from disk on each
step ca renew --daemoncycle.Pain or issue this feature alleviates:
Fixes #1632. Previously
step ca renew --daemonloaded the certificate and private key once at startup and reused them indefinitely. When an external process (e.g., configuration management or rekeying) replaced the certificate and key on disk, the daemon kept renewing the old certificate and wrote it back over the new file, causing a certificate/private-key mismatch.Why is this important to the project (if not answered above):
reloadCert func() (tls.Certificate, error)hook onrenewer(keepingnewRenewerandDaemonsignatures unchanged sorekey --daemonis unaffected), wired inrenewCertificateActionfor file-backed--daemonruns (kmsURI == "").RenewAndPrepareNext, validates that the loaded certificate's public key matches the private key (publicKeysEqual), skips the cycle with an error instead of overwriting disk if they are mismatched, supportsoutFile != certFilefallback tocertFileon external replacement, updatesr.cert/r.key/r.transport.TLSClientConfig.Certificates, and callsr.transport.CloseIdleConnections()when the leaf certificate changed.command/ca/renew_test.gocovering mTLS keep-alive reload, token-based reload, mismatched on-disk keypair protection, and separateoutFileexternal replacement.Local verification:
go test -v -count=3 ./command/ca/...PASS (3/3)go vet ./command/ca/...cleangofmt -l command/ca/renew.go command/ca/renew_test.gocleango build ./cmd/stepOKIs there documentation on how to use this feature? If so, where?
No new flags or configuration changes; existing
step ca renew --daemondocumentation applies.In what environments or workflows is this feature supported?
File-backed
step ca renew --daemonworkflows (both mTLS and token renewal, with or without--out).In what environments or workflows is this feature explicitly NOT supported (if any)?
KMS-backed keys (
--kms), which retain existing behavior.Supporting links/other PRs/issues:
Fixes #1632