Repository navigation
fix(broker): verify the certificate and hostname on rediss broker URLs - #40
Merged
Merged
Conversation
kombu connects to a rediss:// broker without checking the server certificate unless the URL sets ssl_cert_reqs. Add ssl_cert_reqs=required and ssl_check_hostname=true when the URL sets neither, and keep explicit values.
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.
Problem
With a
rediss://broker URL that has no SSL options, kombu connects over TLS but does not check the server certificate. It logsSecure redis scheme specified (rediss) with no ssl options, defaulting to insecure SSL behaviour. The connection is encrypted, but anyone in the network path could impersonate the broker.Changes
Config.broker_urlpassesrediss://URLs throughwith_tls_verification(). If the URL sets nossl_cert_reqs, it addsssl_cert_reqs=requiredandssl_check_hostname=true.CERT_REQUIRED/CERT_NONEstyle values are normalized to the lowercase form that kombu and redis-py accept.redis://URLs are unchanged.CELERY_BROKER_URLrow describes the new behaviour.To keep the old behaviour against a broker with a self-signed certificate, set
?ssl_cert_reqs=nonein the URL.How did you test this code?
Agent-authored.
uv run pytest -qpasses (30 tests). The newtests/test_broker_tls.pycovers the URL rewrite cases, theConfigdefault, and that kombu'sConnection(url).sslcomes out as{"ssl_cert_reqs": ssl.CERT_REQUIRED, "ssl_check_hostname": True}.🤖 Generated with Claude Code