From d29c139960b970b307ead9cc011da069dfb2a331 Mon Sep 17 00:00:00 2001 From: Matt Monaco Date: Fri, 3 Apr 2026 13:57:32 -0400 Subject: [PATCH] Pass server_hostname to wrap_socket for SSL connections 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 --- rabbitpy/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rabbitpy/io.py b/rabbitpy/io.py index 7d9f0c9..fcba88f 100644 --- a/rabbitpy/io.py +++ b/rabbitpy/io.py @@ -249,7 +249,10 @@ def _create_socket( sock = socket.socket(address_family, sock_type, protocol) context = self._get_ssl_context() if context: - return context.wrap_socket(sock=sock) + return context.wrap_socket( + sock=sock, + server_hostname=self._host, + ) return sock def _get_addr_info(self) -> AddrInfo: