From c6d028f50280edd14efa3b1ebc64733c29963e83 Mon Sep 17 00:00:00 2001 From: Pablo Iturrieta <69042881+pabloitu@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:15:21 +0200 Subject: [PATCH] fix: handles URL exception or SSL verifications errors for both python 3.8 and 3.11 inclusive (#231) --- csep/utils/comcat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/csep/utils/comcat.py b/csep/utils/comcat.py index ecaea5f9..1f22cb2a 100644 --- a/csep/utils/comcat.py +++ b/csep/utils/comcat.py @@ -313,7 +313,8 @@ def _search(**newargs): except URLError as URLe: # Fails to verify SSL certificate, when there is a hostname mismatch - if isinstance(URLe.reason, ssl.SSLCertVerificationError) and URLe.reason.verify_code == 62: + if (isinstance(URLe.reason, ssl.SSLCertVerificationError) and URLe.reason.verify_code == 62) \ + or (isinstance(URLe.reason, ssl.SSLError) and URLe.reason.errno == 5): try: context = ssl._create_unverified_context() fh = request.urlopen(url, timeout=TIMEOUT, context=context)