From 5220451b7302fe98c2234ceaa08dbbc5040c8c94 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 22 Jun 2018 18:01:55 +0200 Subject: [PATCH] fix #4457 --- lib/interface.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/interface.py b/lib/interface.py index e4fcb2b5d..dbd41a0db 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -149,7 +149,11 @@ class TcpConnection(threading.Thread, util.PrintError): except: return - if s and self.check_host_name(s.getpeercert(), self.host): + try: + peer_cert = s.getpeercert() + except OSError: + return + if s and self.check_host_name(peer_cert, self.host): self.print_error("SSL certificate signed by CA") return s # get server certificate. @@ -166,7 +170,10 @@ class TcpConnection(threading.Thread, util.PrintError): except: return - dercert = s.getpeercert(True) + try: + dercert = s.getpeercert(True) + except OSError: + return s.close() cert = ssl.DER_cert_to_PEM_cert(dercert) # workaround android bug