Pass server_hostname to wrap_socket for SSL connections#153
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SSLContext.wrap_socket() requires server_hostname when check_hostname is enabled, which is the default for PROTOCOL_TLS_CLIENT. Without it, all amqps:// connections fail with: ValueError: check_hostname requires server_hostname self._host is already available from the parsed AMQP URL. Co-authored-by: Claude <noreply@anthropic.com>
63933b0 to
d29c139
Compare
Problem
All
amqps://connections fail on Python 3.12+ with:_get_ssl_context()creates anSSLContext(ssl.PROTOCOL_TLS_CLIENT), which setscheck_hostname=Trueby default. However,_create_socket()callscontext.wrap_socket(sock=sock)without passingserver_hostname, which Python's SSL module requires when hostname verification is enabled.Fix
Pass
server_hostname=self._hosttowrap_socket().self._hostis already set from the parsed AMQP URL at init time.Reproducer
Summary by CodeRabbit