This error is not catched and stops loop_forever etc., that is very
unexpected. So we catch the error and raise a error that is actually
catched (and better represents the situation)
See also: http://bugs.python.org/issue13721
Change-Id: I495c08ec079290a97caeaf0e7f88116041d8cec6
Signed-off-by: Hmvp <hmvp@hmvp.nl>
return False
def _tls_match_hostname(self):
- cert = self._ssl.getpeercert()
+ try:
+ cert = self._ssl.getpeercert()
+ except AttributeError:
+ # the getpeercert can throw Attribute error: object has no attribute 'peer_certificate'
+ # Don't let that crash the whole client. See also: http://bugs.python.org/issue13721
+ raise ssl.SSLError('Not connected')
+
san = cert.get('subjectAltName')
if san:
have_san_dns = False