Skip to content

fix(broker): verify the certificate and hostname on rediss broker URLs - #40

Merged
langesven merged 1 commit into
mainfrom
sl/verify-broker-tls
Nov 16, 2026
Merged

langesven merged 1 commit into
mainfrom
sl/verify-broker-tls

Conversation

@langesven

Copy link
Copy Markdown
Contributor

Problem

With a rediss:// broker URL that has no SSL options, kombu connects over TLS but does not check the server certificate. It logs Secure 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_url passes rediss:// URLs through with_tls_verification(). If the URL sets no ssl_cert_reqs, it adds ssl_cert_reqs=required and ssl_check_hostname=true.
  • Values already in the URL are kept. CERT_REQUIRED / CERT_NONE style values are normalized to the lowercase form that kombu and redis-py accept. redis:// URLs are unchanged.
  • README: the CELERY_BROKER_URL row describes the new behaviour.

To keep the old behaviour against a broker with a self-signed certificate, set ?ssl_cert_reqs=none in the URL.

How did you test this code?

Agent-authored. uv run pytest -q passes (30 tests). The new tests/test_broker_tls.py covers the URL rewrite cases, the Config default, and that kombu's Connection(url).ssl comes out as {"ssl_cert_reqs": ssl.CERT_REQUIRED, "ssl_check_hostname": True}.

🤖 Generated with Claude Code

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.
@langesven
langesven merged commit 43e2258 into main Nov 16, 2026
12 checks passed
@langesven
langesven deleted the sl/verify-broker-tls branch November 16, 2026 12:43
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.

1 participant