From ca9b38700da0756f46f8cf92a98a901db004ebf3 Mon Sep 17 00:00:00 2001 From: James Myatt Date: Tue, 25 Oct 2016 20:58:07 +0100 Subject: [PATCH] Don't catch ssl.CertificateError in first attempt to wrap_socket Signed-off-by: James Myatt --- src/paho/mqtt/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 41cd522..1937997 100755 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -833,6 +833,9 @@ class Client(object): try: # Try with server_hostname, even it's not supported in certain scenarios sock = self._ssl_context.wrap_socket(sock, server_hostname=self._host) + except ssl.CertificateError: + # CertificateError is derived from ValueError + raise except ValueError: # Python version requires SNI in order to handle server_hostname, but SNI is not available sock = self._ssl_context.wrap_socket(sock) -- GitLab