Add --tls_reload_interval_secs for automatic TLS cert hot reload#7236
Open
oliverlii wants to merge 1 commit intodragonflydb:mainfrom
Open
Add --tls_reload_interval_secs for automatic TLS cert hot reload#7236oliverlii wants to merge 1 commit intodragonflydb:mainfrom
oliverlii wants to merge 1 commit intodragonflydb:mainfrom
Conversation
Production TLS deployments rotate certificates periodically (e.g. via cert-manager, Vault, or ACME). Today Dragonfly requires a manual CONFIG SET tls_cert_file / tls_key_file / tls true sequence via redis-cli to pick up renewed certs, which is error-prone and does not scale across large fleets. Add a new flag --tls_reload_interval_secs (minimum 60, default 0 = disabled) that launches a background fiber to periodically stat() the configured cert, key, and CA files. When any file's mtime changes, the fiber calls ReconfigureTLS() on every listener, which atomically swaps the SSL_CTX. Existing connections are unaffected (SSL_CTX is refcounted); only new handshakes use the updated certificates. Zero downtime, zero keyspace impact. - Add TlsReloadScheduling() fiber with mtime-based change detection - Wire up Init/Shutdown lifecycle (tls_reload_fb_, tls_reload_done_) - Add integration test: overwrite certs on disk, wait for reload, verify old CA rejected and new CA accepted
cc8185f to
8735e4a
Compare
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
Production TLS deployments rotate certificates periodically (e.g. via cert-manager, Vault, or ACME). Today Dragonfly requires a manual
CONFIG SET tls_cert_file/tls_key_file/tls truesequence via redis-cli to pick up renewed certs. This does not scale across large fleets.Changes
--tls_reload_interval_secsflag (minimum 60, default 0 = disabled)TlsReloadScheduling()background fiber that periodicallystat()s the configured cert, key, and CA cert files; when any mtime changes, callsReconfigureTLS()on every listenerSSL_CTXis refcounted, existing connections keep their sessions, only new handshakes use updated certstls_reload_fb_,tls_reload_done_)Testing
test_tls_hot_reload: starts server with TLS, overwrites cert/key files on disk with certs from a different CA, waits for reload timer, verifies old CA rejected, new CA accepted, and existing connection survives